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 <mprivozn(a)redhat.com>
---
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.21.0