From ee66fc3a855129b1682dd6c4844e7908a24a1347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 3 Nov 2021 23:54:12 +0100 Subject: core: fix crash in function hdata_set when pointer value is NULL in hashtable --- src/core/wee-hdata.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/wee-hdata.c b/src/core/wee-hdata.c index 6580349db..d36100dbf 100644 --- a/src/core/wee-hdata.c +++ b/src/core/wee-hdata.c @@ -1049,10 +1049,18 @@ hdata_set (struct t_hdata *hdata, void *pointer, const char *name, return 1; break; case WEECHAT_HDATA_POINTER: - rc = sscanf (value, "%lx", &ptr); - if ((rc != EOF) && (rc != 0)) + if (value) { - *((void **)(pointer + var->offset)) = (void *)ptr; + rc = sscanf (value, "%lx", &ptr); + if ((rc != EOF) && (rc != 0)) + { + *((void **)(pointer + var->offset)) = (void *)ptr; + return 1; + } + } + else + { + *((void **)(pointer + var->offset)) = NULL; return 1; } break; -- cgit v1.2.3