Imported Upstream version 1.6.0
[platform/upstream/augeas.git] / src / internal.c
index e149fe6..847b068 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * internal.c: internal data structures and helpers
  *
- * Copyright (C) 2007-2011 David Lutterkort
+ * Copyright (C) 2007-2015 David Lutterkort
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -52,6 +52,7 @@ int pathjoin(char **path, int nseg, ...) {
             len += strlen(*path) + 1;
             if (REALLOC_N(*path, len) == -1) {
                 FREE(*path);
+                va_end(ap);
                 return -1;
             }
             if (strlen(*path) == 0 || (*path)[strlen(*path)-1] != SEP)
@@ -60,8 +61,10 @@ int pathjoin(char **path, int nseg, ...) {
                 seg += 1;
             strcat(*path, seg);
         } else {
-            if ((*path = malloc(len)) == NULL)
+            if ((*path = malloc(len)) == NULL) {
+                va_end(ap);
                 return -1;
+            }
             strcpy(*path, seg);
         }
     }