Skip to content

Commit 769bdb7

Browse files
committed
fix(gencodecs): check 'json_char' before strlen()
Accessing a NULL ptr will segfault the bot, dealbreaker
1 parent ad14f44 commit 769bdb7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

gencodecs/discord_codecs.PRE.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PP_INCLUDE("types.h")
99

1010
/* Custom JSON encoding macros */
1111
#define GENCODECS_JSON_ENCODER_PTR_json_char(b, buf, size, _var, _type) \
12-
if (0 > (code = jsonb_token(b, buf, size, _var, strlen(_var)))) \
12+
if (0 > (code = jsonb_token(b, buf, size, _var, _var ? strlen(_var) : 0)))\
1313
return code
1414
#define GENCODECS_JSON_ENCODER_size_t(b, buf, size, _var, _type) \
1515
{ \

0 commit comments

Comments
 (0)