]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: fix memory leak in blkid_parse_tag_string()
authorKarel Zak <kzak@redhat.com>
Tue, 19 Nov 2013 16:52:56 +0000 (17:52 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 19 Nov 2013 16:52:56 +0000 (17:52 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/tag.c

index 3a709501376068d30d073d1ccc2a497c3ae94b7a..e095ab1bebcac189e8fa101b51af7f5235f7991d 100644 (file)
@@ -237,14 +237,18 @@ int blkid_parse_tag_string(const char *token, char **ret_type, char **ret_val)
                        goto errout; /* missing closing quote */
                *cp = '\0';
        }
-       value = value && *value ? strdup(value) : NULL;
-       if (!value)
-               goto errout;
+
+       if (ret_val) {
+               value = value && *value ? strdup(value) : NULL;
+               if (!value)
+                       goto errout;
+               *ret_val = value;
+       }
 
        if (ret_type)
                *ret_type = name;
-       if (ret_val)
-               *ret_val = value;
+       else
+               free(name);
 
        return 0;