Skip to content

Commit d20576d

Browse files
authored
bugfix: bus error or SIGSEGV caused by encode not keep buffer.
1 parent 2bfad8f commit d20576d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lua_cjson.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,10 @@ static void json_create_config(lua_State *l)
457457
int i;
458458

459459
cfg = lua_newuserdata(l, sizeof(*cfg));
460+
if (!cfg)
461+
abort();
462+
463+
memset(cfg, 0, sizeof(*cfg));
460464

461465
/* Create GC method to clean up strbuf */
462466
lua_newtable(l);

0 commit comments

Comments
 (0)