This is just a start to see if upstream likes it or not. If it turns out we
want this I can supply more patches - there are plenty of vir.*Free() functions
which doesn't set ptr to NULL.
My aim is to make it more visible where are we using stale pointer. Because if
the pointer is not set to NULL it may happen that the page isn't unmapped, so
on write access we are overwriting something else (perhaps glibc internal
structs). We may get SIGSEGV later on, but it will not show the root cause but
some random location instead. So you often have to run it under valgrind to get
to the real root cause. And I don't need to say how tricky is that, do I?
Of course, it won't catch every stale pointer bug we have, but my aim is to
catch a few at least.
Michal Privoznik (2):
virObjectUnref: Set pointer to NULL on dispose
virCommandFree: Set pointer to NULL
src/fdstream.c | 1 -
src/libvirt_private.syms | 4 ++--
src/qemu/qemu_driver.c | 1 -
src/storage/storage_backend_logical.c | 3 ---
src/util/vircommand.c | 11 ++++++++---
src/util/vircommand.h | 4 +++-
src/util/viridentity.c | 2 +-
src/util/virnetdevveth.c | 1 -
src/util/virobject.c | 13 ++++++++-----
src/util/virobject.h | 5 ++++-
10 files changed, 26 insertions(+), 19 deletions(-)
--
1.8.1.5