diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-03-08 10:06:59 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-03-08 10:09:57 -0800 |
commit | 473bc91c8af9de1e41e9eb3e67107d8496ab61c8 (patch) | |
tree | 8facda7c378278003e83c5dc50fe53bf0a6f3b00 /dive.c | |
parent | dac29e7bc4e417d0fcdac0246a1b534eb704bf85 (diff) | |
download | subsurface-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.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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; |