synk

synchronize files between hosts
Log | Files | Refs | README | LICENSE

commit deb721c47bda91d79cc7b7d6160a8d5b644359d6
parent 41a5e83a69cf024c072941210d90196e213c3f9e
Author: Willy <willyatmailoodotorg>
Date:   Thu Sep  1 08:05:57 +0200

Improve error checking in concat()

Diffstat:
synk.c | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/synk.c b/synk.c @@ -116,15 +116,17 @@ concat(int n, ...) /* count args in the given array */ for (i=0; p[i]; ++i); - /* leave room for a trailing NULL arg if we're at the last array */ + /* Leave room for a NULL arg at the end */ i += n ? 0 : 1; - cat = realloc(cat, (len + i) * sizeof(char *)); - if (!cat) { + tmp = realloc(cat, (len + i) * sizeof(char *)); + if (!tmp) { perror("realloc"); + free(cat); va_end(args); return NULL; } + cat = tmp; memcpy(cat + len, p, i*sizeof(char *)); len += i; }