Skip to content

Commit 5e200de

Browse files
committed
unref: Guard against NULL lwc_strings
1 parent c5b8a02 commit 5e200de

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

include/libwapcaplet/libwapcaplet.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,15 @@ lwc_string_ref(lwc_string *str)
156156
* freed. (Ref count of 1 where string is its own insensitve match
157157
* will also result in the string being freed.)
158158
*/
159-
#define lwc_string_unref(str) { \
160-
lwc_string *__lwc_s = (str); \
161-
assert(__lwc_s != NULL); \
162-
__lwc_s->refcnt--; \
163-
if ((__lwc_s->refcnt == 0) || \
164-
((__lwc_s->refcnt == 1) && (__lwc_s->insensitive == __lwc_s))) \
165-
lwc_string_destroy(__lwc_s); \
159+
#define lwc_string_unref(str) { \
160+
lwc_string *__lwc_s = (str); \
161+
if (__lwc_s != NULL) { \
162+
__lwc_s->refcnt--; \
163+
if ((__lwc_s->refcnt == 0) || \
164+
((__lwc_s->refcnt == 1) && \
165+
(__lwc_s->insensitive == __lwc_s))) \
166+
lwc_string_destroy(__lwc_s); \
167+
} \
166168
}
167169

168170
/**

0 commit comments

Comments
 (0)