summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-03-08 10:06:59 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-03-08 10:09:57 -0800
commit473bc91c8af9de1e41e9eb3e67107d8496ab61c8 (patch)
tree8facda7c378278003e83c5dc50fe53bf0a6f3b00 /dive.c
parentdac29e7bc4e417d0fcdac0246a1b534eb704bf85 (diff)
downloadsubsurface-473bc91c8af9de1e41e9eb3e67107d8496ab61c8.tar.gz
Don't strdup(NULL)
merge_text() could call strdup(NULL) if one pointer was "" and the other NULL. This commit fixes that. Reported-by: fhuberts Analyzed-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/dive.c b/dive.c
index 1b4c78306..da80044ed 100644
--- a/dive.c
+++ b/dive.c
@@ -908,11 +908,11 @@ static char *merge_text(const char *a, const char *b)
if (!a && !b)
return NULL;
if (!a || !*a)
- return strdup(b);
+ return b ? strdup(b) : NULL;
if (!b || !*b)
return strdup(a);
if (!strcmp(a,b))
- return strdup(a);
+ return a ? strdup(a) : NULL;
res = malloc(strlen(a) + strlen(b) + 32);
if (!res)
return (char *)a;