]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/strv: allow NULLs to be inserted into strv
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 22 Jan 2017 21:23:24 +0000 (16:23 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 11 Feb 2017 23:21:06 +0000 (18:21 -0500)
All callers of this function insert non-empty strings, so there's no functional
change.

src/basic/strv.c

index 0eec868eed1f5e0dc46288eadf16b89830d49b7c..60f92e63733c3ae040fa350e2080ecb227188783 100644 (file)
@@ -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) {