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>
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,