Skip to content

Commit

Permalink
Merge pull request #602 from goblint/issue-566
Browse files Browse the repository at this point in the history
Fix imprecise AD.meet with NULL
  • Loading branch information
sim642 authored Feb 18, 2022
2 parents 304cfd6 + f72fde5 commit 4c51356
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cdomains/addressDomain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ struct
else remove Addr.NullPtr x
in
match is_top x, is_top y with
| true, true -> uop x y
| true, true -> no_null (no_null (uop x y) x) y
| false, true -> no_null x y
| true, false -> no_null y x
| false, false -> cop x y
Expand Down
4 changes: 2 additions & 2 deletions tests/regression/27-inv_invariants/15-unknown-null-ptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ int main() {
if (r == NULL)
assert(r == NULL);
else
assert(r != NULL); // TODO
assert(r != NULL);

if (r != NULL)
assert(r != NULL); // TODO
assert(r != NULL);
else
assert(r == NULL);

Expand Down
26 changes: 26 additions & 0 deletions tests/regression/27-inv_invariants/16-sedgewick.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <stddef.h>
#include <assert.h>

struct node {
struct node *left;
struct node *right;
int key;
};

// https://old.reddit.com/r/programminghorror/comments/jgrpcu/on_sedgewicks_original_presentation_for_llrb_trees/
struct node* min(struct node *root) {
struct node *x = root;
while (x != NULL)
x = x->left;
if (x == NULL) // WARN (dead branch)
return NULL;
else
return x;
}

int main() {
struct node *root;
struct node *m = min(root);
assert(m == NULL);
return 0;
}

0 comments on commit 4c51356

Please sign in to comment.