Open WILDWEEGEE opened 6 years ago
<!doctype html>
File: | C:\Users\Gianluca\Documents\CIS 400\GARBAGE/simple.c |
Warning: | line 12, column 32 Dereference of null pointer (loaded from variable 'p') |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | #include <stdio.h> | |||
2 | #include <string.h> | |||
3 | ||||
4 | int main(int argc, char* argv[]) { | |||
5 | int x = 23; | |||
6 | int* p = &x; | |||
7 | ||||
8 | if (argc >= 2 && strcmp(argv[1], "kek") == 0) { | |||
| ||||
9 | p = NULL((void *)0); | |||
10 | } | |||
11 | ||||
12 | printf("The number is %d", *p); | |||
| ||||
13 | ||||
14 | int* z = NULL((void *)0); | |||
15 | ||||
16 | x += *z; | |||
17 | ||||
18 | int arr[10]; | |||
19 | arr[0] = 2; | |||
20 | int y = 11; | |||
21 | p = &y; | |||
22 | arr[*p] = 11; | |||
23 | ||||
24 | return 0; | |||
25 | } |
<!DOCTYPE html>
File: | test.c |
Location: | line 33, column 32 |
Description: | Dereference of null pointer (loaded from variable 'p2') |
1 | #include <stdio.h> | |||
2 | #include <string.h> | |||
3 | #include "helper.h" | |||
4 | ||||
5 | int otherHelper(int* p) { | |||
6 | return *p - 5; | |||
7 | } | |||
8 | ||||
9 | // Dereference pointer without checking if NULL | |||
10 | int helper2(int* p) { | |||
11 | printf("wow\n"); | |||
12 | return *p + 4; | |||
13 | } | |||
14 | ||||
15 | int main(int argc, char* argv[]) { | |||
16 | int num1 = 15; | |||
17 | int num2 = 20; | |||
18 | ||||
19 | int* p1 = &num1; | |||
20 | int* p2 = &num2; | |||
21 | ||||
22 | if (argc >= 2 && strcmp(argv[1], "wow") == 0) { | |||
| ||||
23 | p1 = NULL((void*)0); | |||
24 | } | |||
25 | ||||
26 | if (argc >= 2 && strcmp(argv[1], "test") == 0) { | |||
27 | p2 = NULL((void*)0); | |||
28 | } | |||
29 | ||||
30 | printf("amazing\n"); | |||
31 | ||||
32 | printf("num1 + 4 is %d\n", helper2(p1)); | |||
33 | printf("num2 - 5 is %d\n", *p2); | |||
| ||||
34 | ||||
35 | int* p3 = NULL((void*)0); | |||
36 | ||||
37 | return *p3; | |||
38 | } |
<!DOCTYPE html>
File: | test.c |
Location: | line 33, column 32 |
Description: | Dereference of null pointer (loaded from variable 'p2') |
1 | #include <stdio.h> | |||
2 | #include <string.h> | |||
3 | #include "helper.h" | |||
4 | ||||
5 | int otherHelper(int* p) { | |||
6 | return *p - 5; | |||
7 | } | |||
8 | ||||
9 | // Dereference pointer without checking if NULL | |||
10 | int helper2(int* p) { | |||
11 | printf("wow\n"); | |||
12 | return *p + 4; | |||
13 | } | |||
14 | ||||
15 | int main(int argc, char* argv[]) { | |||
16 | int num1 = 15; | |||
17 | int num2 = 20; | |||
18 | ||||
19 | int* p1 = &num1; | |||
20 | int* p2 = &num2; | |||
21 | ||||
22 | if (argc >= 2 && strcmp(argv[1], "wow") == 0) { | |||
| ||||
23 | p1 = NULL((void*)0); | |||
24 | } | |||
25 | ||||
26 | if (argc >= 2 && strcmp(argv[1], "test") == 0) { | |||
27 | p2 = NULL((void*)0); | |||
28 | } | |||
29 | ||||
30 | printf("amazing\n"); | |||
31 | ||||
32 | printf("num1 + 4 is %d\n", helper2(p1)); | |||
33 | printf("num2 - 5 is %d\n", *p2); | |||
| ||||
34 | ||||
35 | int* p3 = NULL((void*)0); | |||
36 | ||||
37 | return *p3; | |||
38 | } |
This is a header