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 <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Michal Privoznik 2019-04-18 14:03:10 +02:00
parent 39d4f78a8e
commit 14b74ab625

View File

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