smdb.py: print the return_implies value
[smatch.git] / validation / sm_null_deref.c
blob17fbfa4d809fdc99be7552fe9ecd1cedae00ed4e
1 #include "check_debug.h"
3 struct foo {
4 int a;
5 };
7 struct foo *a;
8 struct foo *b;
9 struct foo *c;
10 struct foo *d;
12 static void func (void)
14 struct foo *aa;
15 int ab = 0;
16 int ac = 1;
18 aa->a = 1;
20 if (a) {
21 a->a = 1;
23 a->a = 1;
25 if (a && b) {
26 b->a = 1;
29 if (a || b) {
30 b->a = 1;
33 if (c) {
34 ab = 1;
37 if (ab) {
38 c->a = 1;
41 d = 0;
42 if (c) {
43 d = malloc(sizeof(*d));
44 ac = 2;
47 if (ac) {
48 d->a = 2;
52 * check-name: Null Dereferences
53 * check-command: smatch --spammy -I.. sm_null_deref.c
55 * check-output-start
56 sm_null_deref.c:18 func() error: potentially dereferencing uninitialized 'aa'.
57 sm_null_deref.c:23 func() error: we previously assumed 'a' could be null (see line 20)
58 sm_null_deref.c:25 func() warn: variable dereferenced before check 'a' (see line 23)
59 sm_null_deref.c:30 func() error: we previously assumed 'b' could be null (see line 25)
60 sm_null_deref.c:48 func() error: potential NULL dereference 'd'.
61 * check-output-end