1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 04:20:27 +01:00

Don't fail with assert() in string functions if both strings are NULL.

wstrconcat and wstrappend already support situations in which first OR
second string are NULL, but not if BOTH are NULL.  Fixed that.
This commit is contained in:
Tobias Stoeckmann
2012-05-05 19:42:42 +02:00
committed by Carlos R. Mafra
parent 4a4775f076
commit 9e2d1b3ecf

View File

@@ -208,10 +208,12 @@ char *wstrconcat(char *str1, char *str2)
char *str;
size_t slen;
if (!str1)
if (!str1 && str2)
return wstrdup(str2);
else if (!str2)
else if (str1 && !str2)
return wstrdup(str1);
else if (!str1 && !str2)
return NULL;
slen = strlen(str1) + strlen(str2) + 1;
str = wmalloc(slen);
@@ -228,10 +230,10 @@ char *wstrappend(char *dst, char *src)
{
size_t slen;
if (!dst)
return wstrdup(src);
else if (!src || *src == 0)
if (!src || *src == 0)
return dst;
else if (!dst)
return wstrdup(src);
slen = strlen(dst) + strlen(src) + 1;
dst = wrealloc(dst, slen);