Fix memleak in data_thread_script of edje_cc_out
authorChris Michael <cp.michael@samsung.com>
Mon, 5 Aug 2013 14:32:12 +0000 (15:32 +0100)
committerChris Michael <cp.michael@samsung.com>
Mon, 5 Aug 2013 14:32:12 +0000 (15:32 +0100)
NB: If we are going to exit data_thread_script function due to malloc
failure or fread failure, then we should close the previously fdopen'd
file so that we do not leak 'f'.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/bin/edje/edje_cc_out.c

index c5caf2f9739727bcd85499790e7a312d5cecf6d0..889d9a062df5804c467e6f2ac9f15fe66ad3f6f3 100644 (file)
@@ -1185,6 +1185,7 @@ data_thread_script(void *data, Ecore_Thread *thread EINA_UNUSED)
                            sc->tmpo);
                   sc->errstr = strdup(buf);
                   free(dat);
+                  fclose(f);
                   return;
                }
             snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%i",
@@ -1197,6 +1198,7 @@ data_thread_script(void *data, Ecore_Thread *thread EINA_UNUSED)
              snprintf(buf, sizeof(buf),
                       "Alloc failed for %lu bytes", (unsigned long)size);
              sc->errstr = strdup(buf);
+             fclose(f);
              return;
           }
      }