We'd free only the first element of the vector leaking the rest.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/util/viralloc.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/util/viralloc.h b/src/util/viralloc.h
index 983a6e83d1..6de311259d 100644
--- a/src/util/viralloc.h
+++ b/src/util/viralloc.h
@@ -697,6 +697,10 @@ 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.
+ * See VIR_AUTOLISTPTR for NULL-terminated lists.
*/
# define VIR_AUTOPTR(type) \
__attribute__((cleanup(VIR_AUTOPTR_FUNC_NAME(type)))) type *
@@ -709,6 +713,10 @@ 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.
+ * See VIR_AUTOLISTPTR for NULL-terminated lists.
*/
# define VIR_AUTOCLEAN(type) \
__attribute__((cleanup(VIR_AUTOCLEAN_FUNC_NAME(type)))) type
--
2.20.1