Skip to content

Commit

Permalink
Added CSA samples
Browse files Browse the repository at this point in the history
  • Loading branch information
Anastasia Kazakova committed Sep 22, 2021
1 parent 2789c34 commit 44326d9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions dfa_samples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,33 @@ class UseVal {
}
};

// Context-sensitive analysis
bool isSuccess(int code) {
if (code != -1)
return true;

return false;
}
void global_analysis() {
int code = 1;
if (isSuccess(code))
;
}

int* my_alloc(int length) {
return new int[10];
}
void my_free(int* buf) {
delete buf;
}

void dangling_csa() {
auto buffer1 = my_alloc(10);
auto buffer2 = my_alloc(10);
my_free(buffer2);
buffer1[0] = 1;
buffer2[0] = 2;
}



Expand Down

0 comments on commit 44326d9

Please sign in to comment.