summaryrefslogtreecommitdiffstats
path: root/libblkid/src/tag.c
diff options
context:
space:
mode:
authorKarel Zak2013-11-19 17:52:56 +0100
committerKarel Zak2013-11-19 17:52:56 +0100
commitc1178175e7adb35388a3e34495974d7f24f45d5d (patch)
tree97eac7886cdc0ed5969fced7b826f5c5293d86b5 /libblkid/src/tag.c
parentmount: make NAME=value tags usable for non-root (diff)
downloadkernel-qcow2-util-linux-c1178175e7adb35388a3e34495974d7f24f45d5d.tar.gz
kernel-qcow2-util-linux-c1178175e7adb35388a3e34495974d7f24f45d5d.tar.xz
kernel-qcow2-util-linux-c1178175e7adb35388a3e34495974d7f24f45d5d.zip
libblkid: fix memory leak in blkid_parse_tag_string()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid/src/tag.c')
-rw-r--r--libblkid/src/tag.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libblkid/src/tag.c b/libblkid/src/tag.c
index 3a7095013..e095ab1be 100644
--- a/libblkid/src/tag.c
+++ b/libblkid/src/tag.c
@@ -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;