chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
coverity: fix a couple of bugs found by coverity
[elogind.git]
/
src
/
strv.c
diff --git
a/src/strv.c
b/src/strv.c
index 92851b223375516b5144f52afcc2ca4b471333fd..640ae3f0a3dacddd967834fb1fa5320cd5a58cb6 100644
(file)
--- a/
src/strv.c
+++ b/
src/strv.c
@@
-201,12
+201,19
@@
char **strv_merge_concat(char **a, char **b, const char *suffix) {
if (!(r = new(char*, strv_length(a)+strv_length(b)+1)))
return NULL;
if (!(r = new(char*, strv_length(a)+strv_length(b)+1)))
return NULL;
- for (k = r; *a; k++, a++)
- if (!(*k = strdup(*a)))
- goto fail;
- for (; *b; k++, b++)
- if (!(*k = strappend(*b, suffix)))
+ k = r;
+ if (a)
+ for (; *a; k++, a++) {
+ *k = strdup(*a);
+ if (!*k)
+ goto fail;
+ }
+
+ for (; *b; k++, b++) {
+ *k = strappend(*b, suffix);
+ if (!*k)
goto fail;
goto fail;
+ }
*k = NULL;
return r;
*k = NULL;
return r;