aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhyw0810 <1210612004@qq.com>2024-03-01 09:18:48 +0800
committerGitHub <noreply@github.com>2024-03-01 09:18:48 +0800
commitd20576d5cef3d7aa3b6d62db7aee9d9d5f03cc70 (patch)
tree85da4f432d16ee426e53389c88860e679a873ec9
parent2bfad8f5eeb821357d2ada29506e864ff7ec947e (diff)
downloadlua-cjson-d20576d5cef3d7aa3b6d62db7aee9d9d5f03cc70.tar.gz
lua-cjson-d20576d5cef3d7aa3b6d62db7aee9d9d5f03cc70.tar.bz2
lua-cjson-d20576d5cef3d7aa3b6d62db7aee9d9d5f03cc70.zip
bugfix: bus error or SIGSEGV caused by encode not keep buffer.
-rw-r--r--lua_cjson.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lua_cjson.c b/lua_cjson.c
index 363466c..ae178eb 100644
--- a/lua_cjson.c
+++ b/lua_cjson.c
@@ -457,6 +457,10 @@ static void json_create_config(lua_State *l)
457 int i; 457 int i;
458 458
459 cfg = lua_newuserdata(l, sizeof(*cfg)); 459 cfg = lua_newuserdata(l, sizeof(*cfg));
460 if (!cfg)
461 abort();
462
463 memset(cfg, 0, sizeof(*cfg));
460 464
461 /* Create GC method to clean up strbuf */ 465 /* Create GC method to clean up strbuf */
462 lua_newtable(l); 466 lua_newtable(l);