From 50c4387178328d343ac6daae516620b230cd6195 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Fri, 7 Jun 2019 19:11:23 +0200 Subject: [PATCH] lua: fix memleak --- src/system/luaserver.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/system/luaserver.cpp b/src/system/luaserver.cpp index 53069a69b..86369f2f2 100644 --- a/src/system/luaserver.cpp +++ b/src/system/luaserver.cpp @@ -176,12 +176,12 @@ void *CLuaServer::luaserver_thread(void *arg) { pthread_t wdthr; pthread_create (&wdthr, NULL, luaclient_watchdog, (void *) lsd); - CLuaInstance lua; - lsd->lua = &lua; + CLuaInstance *lua = new CLuaInstance(); + lsd->lua = *&lua; std::string result_code; std::string result_string; std::string error_string; - lua.runScript(lsd->script.c_str(), &lsd->argv, &result_code, &result_string, &error_string); + lua->runScript(lsd->script.c_str(), &lsd->argv, &result_code, &result_string, &error_string); pthread_cancel(wdthr); pthread_join(wdthr, NULL); if (!lsd->died) { @@ -202,7 +202,9 @@ void *CLuaServer::luaserver_thread(void *arg) { rp += error_string_len; CBasicServer::send_data(lsd->fd, result, size); } + delete lua; delete lsd; + Lock(); if (instance) { instance->count--;