Skip to contentSkip to conversation

master - lvmetad: move initialization in the inner loop

PATCH Zdenek Kabelac 1 participant 1 message Oct 13, 2012

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=88c547d1ca83426f4de5371baac885f5500b5487
Commit:        88c547d1ca83426f4de5371baac885f5500b5487
Parent:        7c7ab99843837bd9099ea502c8a34c05fad495c3
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Sat Oct 13 19:15:15 2012 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Sat Oct 13 19:15:15 2012 +0200

lvmetad: move initialization in the inner loop

Set append to NULL in the front of cycle, so the INTERNAL error path is not leading to double-free of append pointer.

---
 libdaemon/client/config-util.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
libdaemon/client/config-util.c +2 -1
index 9b893c6..1f4b55b 100644
@@ -23,7 +23,7 @@
 
 int buffer_append_vf(struct buffer *buf, va_list ap)
 {
-	char *append = NULL;
+	char *append;
 	char *next;
 	int keylen;
 	int64_t value;
@@ -31,6 +31,7 @@ int buffer_append_vf(struct buffer *buf, va_list ap)
 	char *block;
 
 	while ((next = va_arg(ap, char *))) {
+		append = NULL;
 		if (!strchr(next, '=')) {
 			log_error(INTERNAL_ERROR "Bad format string at '%s'", next);
 			goto fail;