From 3d35f78f1205c8a7a4e5dd7ae6525d8bf0e6b0b4 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 18 Nov 2025 20:14:19 +0000 Subject: [PATCH] unref: Guard against NULL lwc_strings --- include/libwapcaplet/libwapcaplet.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include/libwapcaplet/libwapcaplet.h b/include/libwapcaplet/libwapcaplet.h index 57e2e48..be9c3ba 100644 --- a/include/libwapcaplet/libwapcaplet.h +++ b/include/libwapcaplet/libwapcaplet.h @@ -156,13 +156,15 @@ lwc_string_ref(lwc_string *str) * freed. (Ref count of 1 where string is its own insensitve match * will also result in the string being freed.) */ -#define lwc_string_unref(str) { \ - lwc_string *__lwc_s = (str); \ - assert(__lwc_s != NULL); \ - __lwc_s->refcnt--; \ - if ((__lwc_s->refcnt == 0) || \ - ((__lwc_s->refcnt == 1) && (__lwc_s->insensitive == __lwc_s))) \ - lwc_string_destroy(__lwc_s); \ +#define lwc_string_unref(str) { \ + lwc_string *__lwc_s = (str); \ + if (__lwc_s != NULL) { \ + __lwc_s->refcnt--; \ + if ((__lwc_s->refcnt == 0) || \ + ((__lwc_s->refcnt == 1) && \ + (__lwc_s->insensitive == __lwc_s))) \ + lwc_string_destroy(__lwc_s); \ + } \ } /**