From 7df0cc8c37ad0d10adc2181e6c3605049f9566f1 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 6 Aug 2013 03:31:59 +0200 Subject: Using shared_ptrs to properly delete our LuaExecFile in all cases. --- src/LuaLoad.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/LuaLoad.cc b/src/LuaLoad.cc index de7501f..a2f12ea 100644 --- a/src/LuaLoad.cc +++ b/src/LuaLoad.cc @@ -1,3 +1,5 @@ +#include + #include "LuaLoad.h" #include "LuaTask.h" #include "Buffer.h" @@ -37,19 +39,17 @@ struct sLua_LuaLoad { h = new Input(L.tostring()); status = OPENING; } - LuaExecFile * execFile = NULL; + std::shared_ptr execFile(new LuaExecFile(h)); return L.yield(Future([L, status, h, execFile]() mutable { switch (status) { case OPENING: h.asA()->open(); status = CREATETASK; case CREATETASK: - execFile = new LuaExecFile(h); status = WAITTASK; execFile->exec(L); case WAITTASK: - execFile->throwError(); // will induce a memory leak in case of an actual error. - delete execFile; + execFile->throwError(); } return 0; })); -- cgit v1.2.3