mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00: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:
parent
2eada815b5
commit
e2d13d607f
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user