libvirt/libvirt-storage-rbd-use-VIR_REALLOC-in-the-loop.patch

36 lines
1.2 KiB
Diff
Raw Normal View History

2019-09-30 10:58:53 -04:00
From 51cf4c75664fd6653a3bf9cb8b83a5a1a0496e5f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Fri, 12 Jul 2019 16:09:32 +0200
Subject: [PATCH] storage: rbd: use VIR_REALLOC in the loop
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If there are more than 16 images, the memory allocated in images
might be leaked on subsequent execution(s).
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry-picked from commit d43bc53eddd49c8c22cb52f8b6554e1f7d4216f8)
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
---
src/storage/storage_backend_rbd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 315bef2..d305628 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -620,7 +620,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDStatePtr ptr)
size_t i;
while (true) {
- if (VIR_ALLOC_N(images, nimages) < 0)
+ if (VIR_REALLOC_N(images, nimages) < 0)
goto error;
rc = rbd_list2(ptr->ioctx, images, &nimages);
--
2.19.1