summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/shared/strv.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/shared/strv.c b/src/shared/strv.c
index aed45d2612..2d556f4a07 100644
--- a/src/shared/strv.c
+++ b/src/shared/strv.c
@@ -372,15 +372,26 @@ fail:
int strv_extend(char ***l, const char *value) {
char **c;
+ char *v;
+ unsigned n;
if (!value)
return 0;
- c = strv_append(*l, value);
- if (!c)
+ v = strdup(value);
+ if (!v)
return -ENOMEM;
- strv_free(*l);
+ n = strv_length(*l);
+ c = realloc(*l, sizeof(char*) * (n + 2));
+ if (!c) {
+ free(v);
+ return -ENOMEM;
+ }
+
+ c[n] = v;
+ c[n+1] = NULL;
+
*l = c;
return 0;
}