compiler/libec: Fixed new memory leaks
authorJerome St-Louis <jerome@ecere.com>
Wed, 9 Jul 2014 09:37:49 +0000 (05:37 -0400)
committerJerome St-Louis <jerome@ecere.com>
Wed, 9 Jul 2014 09:37:49 +0000 (05:37 -0400)
compiler/bootstrap/libec/bootstrap/freeAst.c
compiler/bootstrap/libec/bootstrap/pass15.c
compiler/libec/src/freeAst.ec
compiler/libec/src/pass15.ec

index ebe1b5f..2301fa0 100644 (file)
@@ -2711,6 +2711,11 @@ if(spec->__anon1.__anon1.templateArgs)
 FreeList(spec->__anon1.__anon1.templateArgs, (void *)(FreeTemplateArgument));
 spec->__anon1.__anon1.templateArgs = (((void *)0));
 }
+if(spec->__anon1.__anon1.nsSpec)
+{
+FreeSpecifier(spec->__anon1.__anon1.nsSpec);
+spec->__anon1.__anon1.nsSpec = (((void *)0));
+}
 break;
 case 5:
 if(spec->__anon1.__anon1.extDecl)
index 940b311..c7c4df9 100644 (file)
@@ -12428,7 +12428,6 @@ struct External * _DeclareStruct(struct External * neededBy, const char * name,
 struct External * external = (((void *)0));
 struct Symbol * classSym = FindClass(name);
 struct __ecereNameSpace__ecere__sys__OldList * curDeclarations = (((void *)0));
-struct Specifier * curSpec = (((void *)0));
 
 if(!inCompiler || !classSym)
 return (((void *)0));
@@ -12444,7 +12443,6 @@ struct Specifier * spec;
 for(spec = external->__anon1.declaration->__anon1.__anon1.specifiers ? (*external->__anon1.declaration->__anon1.__anon1.specifiers).first : (((void *)0)); spec; spec = spec->next)
 if(spec->type == 3 || spec->type == 4)
 {
-curSpec = spec;
 curDeclarations = spec->__anon1.__anon2.definitions;
 break;
 }
@@ -12455,15 +12453,14 @@ struct __ecereNameSpace__ecere__sys__OldList * specifiers, * declarators;
 struct __ecereNameSpace__ecere__sys__OldList * declarations = (((void *)0));
 char structName[1024];
 unsigned int addedPadding = 0;
+struct Specifier * curSpec = (((void *)0));
 
 classSym->declaring++;
 if(strchr(classSym->string, '<'))
 {
 if(classSym->__anon1.registered->templateClass)
-{
 external = _DeclareStruct(neededBy, classSym->__anon1.registered->templateClass->fullName, skipNoHead, needDereference, fwdDecl);
 classSym->declaring--;
-}
 return external;
 }
 structName[0] = 0;
@@ -12485,6 +12482,18 @@ if(!skipNoHead)
 declarations = MkList();
 AddMembers(external, declarations, classSym->__anon1.registered, 0, (((void *)0)), classSym->__anon1.registered, &addedPadding);
 }
+if(external->__anon1.declaration)
+{
+struct Specifier * spec;
+
+for(spec = external->__anon1.declaration->__anon1.__anon1.specifiers ? (*external->__anon1.declaration->__anon1.__anon1.specifiers).first : (((void *)0)); spec; spec = spec->next)
+if(spec->type == 3 || spec->type == 4)
+{
+curSpec = spec;
+curDeclarations = spec->__anon1.__anon2.definitions;
+break;
+}
+}
 if(declarations && (!(*declarations).count || ((*declarations).count == 1 && addedPadding)))
 {
 FreeList(declarations, (void *)(FreeClassDef));
@@ -14138,7 +14147,13 @@ ListAdd(specs, MkSpecifier(BOOL));
 else if(dest->kind == 1 && (source->kind == 24 || source->kind == 1 || source->kind == 15 || source->kind == 2 || source->kind == 3) && (dest->isSigned ? (value >= -128 && value <= 127) : (value >= 0 && value <= 255)))
 {
 if(source->kind == 3)
+{
+FreeType(dest);
+FreeType(source);
+if(backupSourceExpType)
+FreeType(backupSourceExpType);
 return 1;
+}
 else
 {
 specs = MkList();
@@ -14150,7 +14165,13 @@ ListAdd(specs, MkSpecifier(CHAR));
 else if(dest->kind == 2 && (source->kind == 15 || source->kind == 24 || source->kind == 1 || source->kind == 2 || (source->kind == 3 && (dest->isSigned ? (value >= -32768 && value <= 32767) : (value >= 0 && value <= 65535)))))
 {
 if(source->kind == 3)
+{
+FreeType(dest);
+FreeType(source);
+if(backupSourceExpType)
+FreeType(backupSourceExpType);
 return 1;
+}
 else
 {
 specs = MkList();
index cec6052..73eee2e 100644 (file)
@@ -286,6 +286,11 @@ void FreeSpecifierContents(Specifier spec)
             FreeList(spec.templateArgs, FreeTemplateArgument);
             spec.templateArgs = null;
          }
+         if(spec.nsSpec)
+         {
+            FreeSpecifier(spec.nsSpec);
+            spec.nsSpec = null;
+         }
          break;
       case extendedSpecifier:
          if(spec.extDecl)
index 8e95be0..7b404b1 100644 (file)
@@ -1155,7 +1155,6 @@ External _DeclareStruct(External neededBy, const char * name, bool skipNoHead, b
    External external = null;
    Symbol classSym = FindClass(name);
    OldList * curDeclarations = null;
-   Specifier curSpec = null;
 
    if(!inCompiler || !classSym) return null;
 
@@ -1175,7 +1174,6 @@ External _DeclareStruct(External neededBy, const char * name, bool skipNoHead, b
       for(spec = external.declaration.specifiers ? external.declaration.specifiers->first : null; spec; spec = spec.next)
          if(spec.type == structSpecifier || spec.type == unionSpecifier)
          {
-            curSpec = spec;
             curDeclarations = spec.definitions;
             break;
          }
@@ -1187,16 +1185,15 @@ External _DeclareStruct(External neededBy, const char * name, bool skipNoHead, b
       OldList * declarations = null;
       char structName[1024];
       bool addedPadding = false;
+      Specifier curSpec = null;
 
       classSym.declaring++;
 
       if(strchr(classSym.string, '<'))
       {
          if(classSym.registered.templateClass)
-         {
             external = _DeclareStruct(neededBy, classSym.registered.templateClass.fullName, skipNoHead, needDereference, fwdDecl);
-            classSym.declaring--;
-         }
+         classSym.declaring--;
          return external;
       }
 
@@ -1222,6 +1219,18 @@ External _DeclareStruct(External neededBy, const char * name, bool skipNoHead, b
             AddMembers(external, declarations, classSym.registered, false, null, classSym.registered, &addedPadding);
          }
 
+         if(external.declaration)
+         {
+            Specifier spec;
+            for(spec = external.declaration.specifiers ? external.declaration.specifiers->first : null; spec; spec = spec.next)
+               if(spec.type == structSpecifier || spec.type == unionSpecifier)
+               {
+                  curSpec = spec;
+                  curDeclarations = spec.definitions;
+                  break;
+               }
+         }
+
          if(declarations && (!declarations->count || (declarations->count == 1 && addedPadding)))
          {
             FreeList(declarations, FreeClassDef);
@@ -3928,7 +3937,12 @@ bool MatchTypeExpression(Expression sourceExp, Type dest, OldList conversions, b
          (dest.isSigned ? (value >= -128 && value <= 127) : (value >= 0 && value <= 255)))
       {
          if(source.kind == intType)
+         {
+            FreeType(dest);
+            FreeType(source);
+            if(backupSourceExpType) FreeType(backupSourceExpType);
             return true;
+         }
          else
          {
             specs = MkList();
@@ -3940,7 +3954,12 @@ bool MatchTypeExpression(Expression sourceExp, Type dest, OldList conversions, b
          (source.kind == intType && (dest.isSigned ? (value >= -32768 && value <= 32767) : (value >= 0 && value <= 65535)))))
       {
          if(source.kind == intType)
+         {
+            FreeType(dest);
+            FreeType(source);
+            if(backupSourceExpType) FreeType(backupSourceExpType);
             return true;
+         }
          else
          {
             specs = MkList();