diff --git a/src/utils.c b/src/utils.c index d3e5787..094a748 100644 --- a/src/utils.c +++ b/src/utils.c @@ -78,6 +78,8 @@ char *string_append(char *a, const char *b, const char *sep) { if (!a) return g_strdup(b); + if (!b) + return a; char *new; if (!sep) diff --git a/test/utils.c b/test/utils.c index bccdd60..6fcee97 100644 --- a/test/utils.c +++ b/test/utils.c @@ -91,6 +91,8 @@ TEST test_string_append(void) ASSERT_STR_EQ("a", (exp = string_append(g_strdup("a"), "", NULL))); g_free(exp); + ASSERT_STR_EQ("a", (exp = string_append(g_strdup("a"), NULL, "_sep_"))); + g_free(exp); ASSERT_EQ(NULL, (exp = string_append(NULL, NULL, "_sep_"))); g_free(exp);