git.annexia.org
/
libguestfs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e0c3093
)
daemon: debug segv correct use of dereferencing NULL.
master
author
Richard W.M. Jones
<rjones@redhat.com>
Mon, 9 Jan 2012 16:55:49 +0000
(16:55 +0000)
committer
Richard W.M. Jones
<rjones@redhat.com>
Mon, 9 Jan 2012 16:55:49 +0000
(16:55 +0000)
daemon/debug.c
patch
|
blob
|
history
diff --git
a/daemon/debug.c
b/daemon/debug.c
index
31cef46
..
522012f
100644
(file)
--- 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;
}