jacob-navia / ccl

This is the code that was previously in code.google.com/p/ccl
46 stars 14 forks source link

one memory leak and resource leak fixed, now the rest of them (4) #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
diff -uBb strcollection.c.org strcollection.c
--- strcollection.c.org 2011-03-01 11:49:57.397800620 +0100
+++ strcollection.c 2011-03-01 11:54:29.966477540 +0100
@@ -1166,17 +1166,23 @@
        return NULL;
    }
    result = iStringCollection.Create(10);
-   if (result == NULL)
+   if (result == NULL) {
+       close(f);
        return NULL;
+   }
    r = GetLine(&line,&llen,f,mm);
    while (r >= 0) {
        if (iStringCollection.Add(result,line) <= 0) {
            Finalize(result);
+           free(line);
+           close(f);
            return NULL;
        }
        r = GetLine(&line,&llen,f,mm);
    }
    if (r != EOF) {
+       free(line);
+       close(f);
        Finalize(result);
        return NULL;
    }

Original issue reported on code.google.com by oetelaar.automatisering on 1 Mar 2011 at 10:56

GoogleCodeExporter commented 8 years ago
Oops, made a mistake,
close(f) should read fclose(f)
Here is new patch :

diff -uBb strcollection.c.org strcollection.c
--- strcollection.c.org 2011-03-01 11:49:57.397800620 +0100
+++ strcollection.c 2011-03-01 12:06:47.376789156 +0100
@@ -1166,17 +1166,23 @@
        return NULL;
    }
    result = iStringCollection.Create(10);
-   if (result == NULL)
+   if (result == NULL) {
+       fclose(f);
        return NULL;
+   }
    r = GetLine(&line,&llen,f,mm);
    while (r >= 0) {
        if (iStringCollection.Add(result,line) <= 0) {
            Finalize(result);
+           free(line);
+           fclose(f);
            return NULL;
        }
        r = GetLine(&line,&llen,f,mm);
    }
    if (r != EOF) {
+       free(line);
+       fclose(f);
        Finalize(result);
        return NULL;
    }

Original comment by oetelaar.automatisering on 1 Mar 2011 at 11:08

GoogleCodeExporter commented 8 years ago
I am sorry I did not read this part before. Excuse me and many thanks for the
bug fixes.

Please email me at
jacob@jacob.remcomp.fr

Original comment by jacobnav...@gmail.com on 8 Mar 2011 at 11:09

GoogleCodeExporter commented 8 years ago
Fixed

Original comment by jacobnav...@gmail.com on 15 Apr 2011 at 10:50