From 4964f94de164a4bfb7ddee6c965cdcd7a4102eef Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 23 Sep 2016 08:26:36 +0200 Subject: [PATCH] - added a destructor zo DFsScript, because if this gets deleted outside the GC process it'll leave an allocated buffer behind, so make sure it always gets destroyed. --- src/fragglescript/t_script.cpp | 13 +++++++++++++ src/fragglescript/t_script.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/fragglescript/t_script.cpp b/src/fragglescript/t_script.cpp index bbf333acf..f1376b7eb 100644 --- a/src/fragglescript/t_script.cpp +++ b/src/fragglescript/t_script.cpp @@ -162,6 +162,19 @@ DFsScript::DFsScript() lastiftrue = false; } +//========================================================================== +// +// This is here to delete the locally allocated buffer in case this +// gets forcibly destroyed +// +//========================================================================== + +DFsScript::~DFsScript() +{ + if (data != NULL) delete[] data; + data = NULL; +} + //========================================================================== // // diff --git a/src/fragglescript/t_script.h b/src/fragglescript/t_script.h index 7f89652e6..3734e16b8 100644 --- a/src/fragglescript/t_script.h +++ b/src/fragglescript/t_script.h @@ -336,6 +336,7 @@ public: // true or false DFsScript(); + ~DFsScript(); void Destroy(); void Serialize(FSerializer &ar);