WILDWEEGEE / test_repo

Testing first GitHub app
0 stars 3 forks source link

Test branch #42

Closed WILDWEEGEE closed 6 years ago

bugdiff[bot] commented 6 years ago

<!DOCTYPE html>

Bug Summary

File:test.c
Location:line 37, column 12
Description:Dereference of null pointer (loaded from variable 'p3')

Annotated Source Code

1#include <stdio.h>
2#include <string.h>
3#include "helper.h"
4
5int otherHelper(int* p) {
6 return *p - 5;
7}
8
9// Dereference pointer without checking if NULL
10int helper2(int* p) {
11 printf("wow\n");
12 return *p + 4;
13}
14
15int 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) {
1
Assuming 'argc' is < 2
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);
2
'p3' initialized to a null pointer value
36
37 return *p3;
3
Dereference of null pointer (loaded from variable 'p3')
38}
bugdiff[bot] commented 6 years ago

<!DOCTYPE html>

Bug Summary

File:test.c
Location:line 33, column 32
Description:Dereference of null pointer (loaded from variable 'p2')

Annotated Source Code

1#include <stdio.h>
2#include <string.h>
3#include "helper.h"
4
5int otherHelper(int* p) {
6 return *p - 5;
7}
8
9// Dereference pointer without checking if NULL
10int helper2(int* p) {
11 printf("wow\n");
12 return *p + 4;
13}
14
15int 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) {
1
Assuming 'argc' is >= 2
2
Taking false branch
23 p1 = NULL((void*)0);
24 }
25
26 if (argc >= 2 && strcmp(argv[1], "test") == 0) {
3
Taking true branch
27 p2 = NULL((void*)0);
4
Null pointer value stored to 'p2'
28 }
29
30 printf("amazing\n");
31
32 printf("num1 + 4 is %d\n", helper2(p1));
33 printf("num2 - 5 is %d\n", *p2);
5
Dereference of null pointer (loaded from variable 'p2')
34
35 int* p3 = NULL((void*)0);
36
37 return *p3;
38}