From 7c6d1bb8b671095af88a917b927a27634586e253 Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Sat, 5 Jul 2014 18:24:46 -0400 Subject: [PATCH] compiler/libec: Fixed memory leak in ProcessTypeSpecs - enumName was being copied again when it was already copied by CopyTypeInto() --- compiler/bootstrap/libec/bootstrap/ast.c | 1 - compiler/bootstrap/libec/bootstrap/freeAst.c | 1 - compiler/libec/src/ast.ec | 2 +- compiler/libec/src/freeAst.ec | 3 +-- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/compiler/bootstrap/libec/bootstrap/ast.c b/compiler/bootstrap/libec/bootstrap/ast.c index 127172b..7f2fd13 100644 --- a/compiler/bootstrap/libec/bootstrap/ast.c +++ b/compiler/bootstrap/libec/bootstrap/ast.c @@ -4601,7 +4601,6 @@ struct Type * dummy = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_T FreeType(dummy); CopyTypeInto(specType, symbol->type); specType->constant = isConstant; -specType->typeName = __ecereNameSpace__ecere__sys__CopyString(symbol->type->name); } else if(!isTypedef) { diff --git a/compiler/bootstrap/libec/bootstrap/freeAst.c b/compiler/bootstrap/libec/bootstrap/freeAst.c index 344e55a..8352ab1 100644 --- a/compiler/bootstrap/libec/bootstrap/freeAst.c +++ b/compiler/bootstrap/libec/bootstrap/freeAst.c @@ -1260,7 +1260,6 @@ case 15: { struct __ecereNameSpace__ecere__sys__NamedLink64 * member, * next; -if(type->__anon1.__anon1.enumName) (__ecereNameSpace__ecere__com__eSystem_Delete(type->__anon1.__anon1.enumName), type->__anon1.__anon1.enumName = 0); for(member = type->__anon1.__anon1.members.first; member; member = next) { diff --git a/compiler/libec/src/ast.ec b/compiler/libec/src/ast.ec index 6cf7333..5a98af2 100644 --- a/compiler/libec/src/ast.ec +++ b/compiler/libec/src/ast.ec @@ -2249,6 +2249,7 @@ public Symbol FindClass(const char * name) void CopyTypeInto(Type type, Type src) { type = *src; + type.name = CopyString(src.name); type.typeName = CopyString(src.typeName); type.refCount = 1; @@ -2414,7 +2415,6 @@ static Type ProcessTypeSpecs(OldList specs, bool assumeEllipsis, bool keepTypeNa CopyTypeInto(specType, symbol.type); specType.constant = isConstant; - specType.typeName = CopyString(symbol.type.name); } else if(!isTypedef) // !specType.kind) // TESTING THIS FOR enum / typedef problem { diff --git a/compiler/libec/src/freeAst.ec b/compiler/libec/src/freeAst.ec index 1f1cea6..cec6052 100644 --- a/compiler/libec/src/freeAst.ec +++ b/compiler/libec/src/freeAst.ec @@ -28,8 +28,7 @@ public void FreeType(Type type) case enumType: { NamedLink64 member, next; - if(type.enumName) - delete type.enumName; + delete type.enumName; for(member = type.members.first; member; member = next) { next = member.next; -- 1.8.3.1