Skip to contentSkip to conversation

master - lvmetad: check result of buffer_realloc

PATCH Zdenek Kabelac 1 participant 1 message Oct 12, 2012

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5c792f620b3448a6bbbe7dc10f9210ad3383d977
Commit:        5c792f620b3448a6bbbe7dc10f9210ad3383d977
Parent:        c4dcbf67a3d19bf4a91b4b72e3e230583a8ee2da
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Fri Oct 12 10:50:07 2012 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Fri Oct 12 10:59:10 2012 +0200

lvmetad: check result of buffer_realloc

---
 libdaemon/client/config-util.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
libdaemon/client/config-util.c +3 -2
index 8aa9ed2..a65a2cc 100644
@@ -289,8 +289,9 @@ int buffer_append(struct buffer *buf, const char *string)
 {
 	int len = strlen(string);
 
-	if (buf->allocated - buf->used <= len)
-		buffer_realloc(buf, len + 1);
+	if ((buf->allocated - buf->used <= len) &&
+	    !buffer_realloc(buf, len + 1))
+                return 0;
 
 	strcpy(buf->mem + buf->used, string);
 	buf->used += len;