[PATCH v2 4/4] util: alloc: Note that VIR_AUTOPTR/VIR_AUTOCLEAN must not be used with vectors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We'd free only the first element of the vector leaking the rest.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/util/viralloc.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/util/viralloc.h b/src/util/viralloc.h
index 15451d4673..572b7d1c1c 100644
--- a/src/util/viralloc.h
+++ b/src/util/viralloc.h
@@ -650,6 +650,9 @@ void virAllocTestHook(void (*func)(int, void*), void *data);
  * the variable declared with it by calling the function
  * defined by VIR_DEFINE_AUTOPTR_FUNC when the variable
  * goes out of scope.
+ *
+ * Note that this macro must NOT be used with vectors! The cleaning function
+ * will not free any elements beyond the first.
  */
 # define VIR_AUTOPTR(type) \
     __attribute__((cleanup(VIR_AUTOPTR_FUNC_NAME(type)))) type *
@@ -662,6 +665,9 @@ void virAllocTestHook(void (*func)(int, void*), void *data);
  * when the variable goes out of scope.
  * The cleanup function is registered by VIR_DEFINE_AUTOCLEAN_FUNC macro for
  * the given type.
+ *
+ * Note that this macro must NOT be used with vectors! The cleaning function
+ * will not free any elements beyond the first.
  */
 # define VIR_AUTOCLEAN(type) \
     __attribute__((cleanup(VIR_AUTOCLEAN_FUNC_NAME(type)))) type
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux