summaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-21 21:43:38 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-21 21:53:53 -0700
commit66375689b8cd110355656203979f5640ecf05193 (patch)
tree41cae26b0af6e11a95adf0887504fc2755f19694 /file.c
parent18d52ec86efcc4e42f2bad0fc47ac1a3d5b69435 (diff)
downloadsubsurface-66375689b8cd110355656203979f5640ecf05193.tar.gz
Prevent null dereference
In each case there are scenarios where we would have dereferenced NULL. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'file.c')
-rw-r--r--file.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/file.c b/file.c
index 20b21f115..7b6f09a1c 100644
--- a/file.c
+++ b/file.c
@@ -499,7 +499,7 @@ char *parse_mkvi_value(const char *haystack, const char *needle)
terminator = '\r';
}
*endptr = 0;
- ret = strdup(valueptr);
+ ret = copy_string(valueptr);
*endptr = terminator;
}
@@ -513,12 +513,11 @@ char *next_mkvi_key(const char *haystack)
if ((valueptr = strstr(haystack, "\n")) != NULL) {
valueptr += 1;
- }
- if ((endptr = strstr(valueptr, ": ")) != NULL) {
- *endptr = 0;
- ret = strdup(valueptr);
- *endptr = ':';
-
+ if ((endptr = strstr(valueptr, ": ")) != NULL) {
+ *endptr = 0;
+ ret = strdup(valueptr);
+ *endptr = ':';
+ }
}
return ret;
}