[libvirt] [PATCH 2/5] util: object: Reset pointer when unrefing object in virObjectAutoUnref

Peter Krempa pkrempa at redhat.com
Tue Feb 26 17:08:09 UTC 2019


The helper function is used by the VIR_AUTOUNREF macro. Prior art is to
clear the pointer even if the variable goes out of scope.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/util/virobject.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/util/virobject.c b/src/util/virobject.c
index a4cbd08077..f08c18ce44 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -372,6 +372,7 @@ virObjectAutoUnref(void *objptr)
 {
     virObjectPtr *obj = objptr;
     virObjectUnref(*obj);
+    *obj = NULL;
 }


-- 
2.20.1




More information about the libvir-list mailing list