From 97fa6355cc514aff0fd0d87fa4cdd2f51485a2a2 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 6 Nov 2015 12:41:56 +0300 Subject: [PATCH] Fix memory leaks in IdList::{MoveSelfInto,DeepCopyInto}. Note that this requires IdLists to be zero-initialized to work correctly. --- src/dsc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dsc.h b/src/dsc.h index c8b37a7..c428435 100644 --- a/src/dsc.h +++ b/src/dsc.h @@ -348,12 +348,14 @@ public: } void MoveSelfInto(IdList *l) { + l->Clear(); memcpy(l, this, sizeof(*this)); elemsAllocated = n = 0; elem = NULL; } void DeepCopyInto(IdList *l) { + l->Clear(); l->elem = (T *)MemAlloc(elemsAllocated * sizeof(elem[0])); memcpy(l->elem, elem, elemsAllocated * sizeof(elem[0])); l->elemsAllocated = elemsAllocated;