From 6398a42daddd4c570f0f77a82ffa8877cd44d8ba Mon Sep 17 00:00:00 2001 From: Abhijith Date: Wed, 7 Dec 2016 18:00:03 -0800 Subject: [PATCH] Placement new occurances need explicit delete --- libs/core/pxt.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/core/pxt.cpp b/libs/core/pxt.cpp index 5295de84..af031013 100644 --- a/libs/core/pxt.cpp +++ b/libs/core/pxt.cpp @@ -131,7 +131,9 @@ namespace pxt { if (refmask[i]) decr(r->fields[i]); r->fields[i] = 0; } - delete r; + //RefRecord is allocated using placement new + r->~RefRecord(); + ::operator delete(r); } void RefRecord_print(RefRecord *r) @@ -259,7 +261,9 @@ namespace pxt { decr(fields[i]); fields[i] = 0; } - delete this; + //RefAction is allocated using placement new + this->~RefAction(); + ::operator delete(this); } void RefAction::print()