From 14b74ab625f4cc472e4fa033f3cc4db676be0ba2 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 18 Apr 2019 14:03:10 +0200 Subject: [PATCH] virBuffer: Try harder to free buffer Currently, the way virBufferFreeAndReset() works is it relies on virBufferContentAndReset() to fetch the buffer content which is then freed. This works as long as there is no bug in virBuffer* implementation (not true apparently). Explicitly call free() over buffer content. Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/util/virbuffer.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c index b2ae7963a1..ac03b15a61 100644 --- a/src/util/virbuffer.c +++ b/src/util/virbuffer.c @@ -281,9 +281,8 @@ virBufferContentAndReset(virBufferPtr buf) */ void virBufferFreeAndReset(virBufferPtr buf) { - char *str = virBufferContentAndReset(buf); - - VIR_FREE(str); + if (buf) + virBufferSetError(buf, 0); } /** -- 2.47.2