Skip to content

Commit

Permalink
fix(gencodecs): check 'json_char' before strlen()
Browse files Browse the repository at this point in the history
Accessing a NULL ptr will segfault the bot, dealbreaker
  • Loading branch information
lcsmuller committed Jul 8, 2023
1 parent ad14f44 commit 769bdb7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gencodecs/discord_codecs.PRE.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PP_INCLUDE("types.h")

/* Custom JSON encoding macros */
#define GENCODECS_JSON_ENCODER_PTR_json_char(b, buf, size, _var, _type) \
if (0 > (code = jsonb_token(b, buf, size, _var, strlen(_var)))) \
if (0 > (code = jsonb_token(b, buf, size, _var, _var ? strlen(_var) : 0)))\
return code
#define GENCODECS_JSON_ENCODER_size_t(b, buf, size, _var, _type) \
{ \
Expand Down

0 comments on commit 769bdb7

Please sign in to comment.