From 1a84d5877d4549f71ff44b8dbb1895eb38b36eee Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 2 Sep 2021 13:55:09 +1000 Subject: Don't free a LuaTree if it doesn't exist. --- src/sledjchisl/sledjchisl.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 8939e2b..23f47a1 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -957,17 +957,20 @@ void freeLuaTree(qtreetbl_t *tree) { qtreetbl_obj_t obj0; - memset((void*)&obj0, 0, sizeof(obj0)); // must be cleared before call - tree->lock(tree); // lock it when thread condition is expected - while(tree->getnext(tree, &obj0, false) == true) + if(tree) { - qLua *q0 = obj0.data; + memset((void*)&obj0, 0, sizeof(obj0)); // must be cleared before call + tree->lock(tree); // lock it when thread condition is expected + while(tree->getnext(tree, &obj0, false) == true) + { + qLua *q0 = obj0.data; - if (LUA_TTABLE == q0->type) - freeLuaTree(q0->v.t); + if (LUA_TTABLE == q0->type) + freeLuaTree(q0->v.t); + } + tree->unlock(tree); + tree->free(tree); } - tree->unlock(tree); - tree->free(tree); } -- cgit v1.1