mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virBitmapToString: Properly handle empty bitmaps
virBitmapNewEmpty() can create a bitmap with 0 length. With such a bitmap virBitmapToString will return NULL rather than an empty string. Initialize the buffer to avoid that. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
@@ -345,6 +345,9 @@ virBitmapToString(virBitmapPtr bitmap)
|
||||
|
||||
sz = bitmap->map_len;
|
||||
|
||||
/* initialize buffer to return empty string for 0 length bitmap */
|
||||
virBufferAdd(&buf, "", -1);
|
||||
|
||||
while (sz--) {
|
||||
virBufferAsprintf(&buf, "%0*lx",
|
||||
VIR_BITMAP_BITS_PER_UNIT / 4,
|
||||
|
||||
Reference in New Issue
Block a user