mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
dac29e7bc4
commit
473bc91c8a
1 changed files with 2 additions and 2 deletions
4
dive.c
4
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue