diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2021-11-03 23:54:12 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2021-11-03 23:54:12 +0100 |
commit | ee66fc3a855129b1682dd6c4844e7908a24a1347 (patch) | |
tree | e3144226e5a6b8dd3756ba76d4796d64e509a83c /src | |
parent | 13472adfffb79fd39aa9d888ae27153dbf28896e (diff) | |
download | weechat-ee66fc3a855129b1682dd6c4844e7908a24a1347.zip |
core: fix crash in function hdata_set when pointer value is NULL in hashtable
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-hdata.c | 14 |
1 files changed, 11 insertions, 3 deletions
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; |