summaryrefslogtreecommitdiffstats
path: root/daemon/debug.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-01-09 16:55:49 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-01-10 15:41:42 +0000
commita4a42881ef741caba593a297a892d9d08066ab0c (patch)
tree4485b5e42ed77cc6f164245b2f5f5f1224b29e7b /daemon/debug.c
parent13a7415595e97c14fa8bdfb330cfdc239d2c233f (diff)
downloadlibguestfs-a4a42881ef741caba593a297a892d9d08066ab0c.tar.gz
libguestfs-a4a42881ef741caba593a297a892d9d08066ab0c.tar.xz
libguestfs-a4a42881ef741caba593a297a892d9d08066ab0c.zip
daemon: debug segv correct use of dereferencing NULL.
(cherry picked from commit 01e717b3c141c509a7200b0a6c560f75815c08f2)
Diffstat (limited to 'daemon/debug.c')
-rw-r--r--daemon/debug.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/daemon/debug.c b/daemon/debug.c
index bb91c9ef..2946662d 100644
--- a/daemon/debug.c
+++ b/daemon/debug.c
@@ -198,7 +198,13 @@ debug_fds (const char *subcmd, int argc, char *const *const argv)
static char *
debug_segv (const char *subcmd, int argc, char *const *const argv)
{
- *(int*)0 = 0;
+ /* http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html
+ * "Dereferencing a NULL Pointer: contrary to popular belief,
+ * dereferencing a null pointer in C is undefined. It is not defined
+ * to trap [...]"
+ */
+ volatile int *ptr = NULL;
+ *ptr = 1;
return NULL;
}