From 473bc91c8af9de1e41e9eb3e67107d8496ab61c8 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 8 Mar 2013 10:06:59 -0800 Subject: 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 Signed-off-by: Dirk Hohndel --- dive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dive.c') 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; -- cgit v1.2.3-70-g09d2