From d20576d5cef3d7aa3b6d62db7aee9d9d5f03cc70 Mon Sep 17 00:00:00 2001 From: hyw0810 <1210612004@qq.com> Date: Fri, 1 Mar 2024 09:18:48 +0800 Subject: bugfix: 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); -- cgit v1.2.3-55-g6feb