this patch adds several missing frees in cgsnapshot tool

Signed-off-by: Ivana Hutarova Varekova <varek...@redhat.com>
---

 src/tools/cgsnapshot.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/tools/cgsnapshot.c b/src/tools/cgsnapshot.c
index fe7496d..30e7b6d 100644
--- a/src/tools/cgsnapshot.c
+++ b/src/tools/cgsnapshot.c
@@ -113,6 +113,10 @@ int load_list(char *filename, struct black_list_type 
**p_list)
                if ((buf[i] == '#') || (buf[i] == '\0'))
                        continue;
 
+               ret = sscanf(buf, "%s", name);
+               if (ret == 0)
+                       continue;
+
                new = (struct black_list_type *)malloc(sizeof
                        (struct black_list_type));
                if (new == NULL) {
@@ -122,15 +126,12 @@ int load_list(char *filename, struct black_list_type 
**p_list)
                        goto err;
                }
 
-               ret = sscanf(buf, "%s", name);
-               if (ret == 0)
-                       continue;
-
                new->name = strdup(name);
                if (new->name == NULL) {
                        fprintf(stderr, "ERROR: Memory allocation problem "
                                "(%s)\n", strerror(errno));
                        ret = 1;
+                       free(new);
                        goto err;
                }
                new->next = NULL;
@@ -145,11 +146,11 @@ int load_list(char *filename, struct black_list_type 
**p_list)
                }
        }
 
-       fclose(fw);
        *p_list = start;
        return 0;
 
 err:
+       fclose(fw);
        new = start;
        while (new != NULL) {
                end = new->next;


------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to