]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virBuffer: Try harder to free buffer
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 18 Apr 2019 12:03:10 +0000 (14:03 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 6 May 2019 07:33:10 +0000 (09:33 +0200)
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@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/util/virbuffer.c

index b2ae7963a15c29a08a6f76dfd606aad79ca343f7..ac03b15a61a612623371c31ed9c27b4d1981491e 100644 (file)
@@ -281,9 +281,8 @@ virBufferContentAndReset(virBufferPtr buf)
  */
 void virBufferFreeAndReset(virBufferPtr buf)
 {
-    char *str = virBufferContentAndReset(buf);
-
-    VIR_FREE(str);
+    if (buf)
+        virBufferSetError(buf, 0);
 }
 
 /**