From 8dc732f1774431560be4cae17f5a118409dc857f Mon Sep 17 00:00:00 2001 From: hyw0810 <1210612004@qq.com> Date: Thu, 29 Feb 2024 20:10:30 +0800 Subject: [PATCH] Fixed bus error or SIGSEGV caused by encode not keep buffer --- lua_cjson.c | 4 ++++ 1 file changed, 4 insertions(+) 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) int i; cfg = lua_newuserdata(l, sizeof(*cfg)); + if (!cfg) + abort(); + + memset(cfg, 0, sizeof(*cfg)); /* Create GC method to clean up strbuf */ lua_newtable(l);