-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 3 regr. tests for trying out global struct variables
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak | ||
#include <stdlib.h> | ||
|
||
typedef struct st { | ||
int *a; | ||
int b; | ||
} st; | ||
|
||
st st_nonptr; | ||
|
||
int main(int argc, char const *argv[]) { | ||
st_nonptr.a = malloc(sizeof(int)); | ||
st_nonptr.a = NULL; | ||
|
||
return 0; //WARN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak | ||
#include <stdlib.h> | ||
|
||
typedef struct st { | ||
int *a; | ||
int b; | ||
} st; | ||
|
||
st *st_ptr; | ||
|
||
int main(int argc, char const *argv[]) { | ||
st_ptr = malloc(sizeof(st)); | ||
st_ptr->a = malloc(sizeof(int)); | ||
st_ptr->a = NULL; | ||
free(st_ptr); | ||
|
||
// Only st_ptr->a is causing trouble here | ||
return 0; //WARN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//PARAM: --set ana.malloc.unique_address_count 1 --set ana.activated[+] memLeak | ||
#include <stdlib.h> | ||
|
||
typedef struct st { | ||
int *a; | ||
int b; | ||
} st; | ||
|
||
typedef struct st2 { | ||
st *st_ptr; | ||
} st2; | ||
|
||
st2 *st_var; | ||
|
||
int main(int argc, char const *argv[]) { | ||
st_var = malloc(sizeof(st2)); | ||
st_var->st_ptr = malloc(sizeof(st)); | ||
st_var->st_ptr->a = malloc(sizeof(int)); | ||
st_var->st_ptr->a = NULL; | ||
free(st_var->st_ptr); | ||
free(st_var); | ||
|
||
// Only st_var->st_ptr->a is causing trouble here | ||
return 0; //WARN | ||
} |