From: Zbigniew Jędrzejewski-Szmek Date: Sun, 22 Jan 2017 21:23:24 +0000 (-0500) Subject: basic/strv: allow NULLs to be inserted into strv X-Git-Tag: v233~59^2~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=18f71a3c8174774c5386c4aba94d54f3b5c36a84;p=thirdparty%2Fsystemd.git basic/strv: allow NULLs to be inserted into strv All callers of this function insert non-empty strings, so there's no functional change. --- diff --git a/src/basic/strv.c b/src/basic/strv.c index 0eec868eed1..60f92e63733 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -564,9 +564,6 @@ int strv_extend_front(char ***l, const char *value) { /* Like strv_extend(), but prepends rather than appends the new entry */ - if (!value) - return 0; - n = strv_length(*l); /* Increase and overflow check. */ @@ -574,9 +571,12 @@ int strv_extend_front(char ***l, const char *value) { if (m < n) return -ENOMEM; - v = strdup(value); - if (!v) - return -ENOMEM; + if (value) { + v = strdup(value); + if (!v) + return -ENOMEM; + } else + v = NULL; c = realloc_multiply(*l, sizeof(char*), m); if (!c) {