aboutsummaryrefslogtreecommitdiff
path: root/src/monkey/bug_null_pointer_exception.c
diff options
context:
space:
mode:
authorSafey A.Halim <safey.allah@gmail.com>2011-04-15 10:02:28 +0000
committerSafey A.Halim <safey.allah@gmail.com>2011-04-15 10:02:28 +0000
commitb1cb1306723f7e953548fb6c6ebe177bb4910948 (patch)
treed13a3a6448dcf8871f8b0c21aa6db6d851a1dfac /src/monkey/bug_null_pointer_exception.c
parenta4116282805cac6b71bc72888ce0d314810fdeb0 (diff)
downloadgnunet-b1cb1306723f7e953548fb6c6ebe177bb4910948.tar.gz
gnunet-b1cb1306723f7e953548fb6c6ebe177bb4910948.zip
Action API detects segmentation fault
Diffstat (limited to 'src/monkey/bug_null_pointer_exception.c')
-rw-r--r--src/monkey/bug_null_pointer_exception.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/monkey/bug_null_pointer_exception.c b/src/monkey/bug_null_pointer_exception.c
index 072904b6d..4accd65af 100644
--- a/src/monkey/bug_null_pointer_exception.c
+++ b/src/monkey/bug_null_pointer_exception.c
@@ -1,13 +1,17 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <string.h> 2#include <string.h>
3 3
4
5struct CrashStruct {
6 const char *crashValue;
7};
8
4void crashFunction() 9void crashFunction()
5{ 10{
6 char *nullString = NULL; 11 struct CrashStruct *crashStruct;
12 crashStruct = NULL;
7 printf("Now the program will crash!\n"); 13 printf("Now the program will crash!\n");
8 if (strcmp(nullString, "A string to compare with") == 0) { 14 crashStruct->crashValue = "hello!";
9 printf("How come?! It had to crash!\n");
10 }
11} 15}
12 16
13int main(int argc, char *argv[]) 17int main(int argc, char *argv[])