id
stringlengths 8
32
| source_file
stringclasses 51
values | original_function_name
stringlengths 2
66
| anonymized_function_name
stringlengths 2
62
| function_code
stringlengths 15
623
| context
listlengths 0
12
| has_bug
bool 2
classes | bug_types
listlengths 0
3
| bug_line_offsets
listlengths 0
3
| bug_absolute_lines
listlengths 0
3
| bug_severities
listlengths 0
3
| bug_traces
listlengths 0
3
| category
stringclasses 7
values | requires_interprocedural
bool 2
classes | start_line
int32 8
932
| end_line
int32 8
936
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lists_003
|
pulse/lists.c
|
delete_one
|
delete_one
|
void delete_one(T* x) { free(x); }
|
[
"#include <stdlib.h>",
"typedef struct node {\n struct node* next;\n} T;"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 35
| 35
|
lists_004
|
pulse/lists.c
|
delete_all
|
delete_all
|
void delete_all(T* x) {
T* temp;
while (x != NULL) {
temp = x;
x = x->next;
free(temp);
}
}
|
[
"#include <stdlib.h>",
"typedef struct node {\n struct node* next;\n} T;"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 37
| 44
|
lists_005
|
pulse/lists.c
|
call_delete_one_ok
|
call_delete_one
|
int call_delete_one() {
T* root = malloc(sizeof(T));
delete_one(root); // no memory leak should be reported here
return 0;
}
|
[
"#include <stdlib.h>",
"typedef struct node {\n struct node* next;\n} T;",
"void delete_one(T* x) { free(x); }\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 46
| 50
|
lists_006
|
pulse/lists.c
|
call_delete_all1_ok
|
call_delete_all1
|
int call_delete_all1() {
T* root = malloc(sizeof(T));
delete_all(root); // no memory leak should be reported here
return 0;
}
|
[
"#include <stdlib.h>",
"typedef struct node {\n struct node* next;\n} T;",
"void delete_all(T* x) {\n T* temp;\n while (x != NULL) {\n temp = x;\n x = x->next;\n free(temp);\n }\n}\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 52
| 56
|
lists_007
|
pulse/lists.c
|
call_delete_all2_ok
|
call_delete_all2
|
int call_delete_all2() {
T* root = malloc(sizeof(T));
if (root != NULL) {
root->next = malloc(sizeof(T));
}
delete_all(root); // no memory leak should be reported here
return 0;
}
|
[
"#include <stdlib.h>",
"typedef struct node {\n struct node* next;\n} T;",
"void delete_all(T* x) {\n T* temp;\n while (x != NULL) {\n temp = x;\n x = x->next;\n free(temp);\n }\n}\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 58
| 65
|
memcpy_001
|
pulse/memcpy.c
|
memcpy_ok
|
memcpy
|
void memcpy() {
X x;
X* p = malloc(sizeof(X));
if (p)
memcpy(p, &x, sizeof(X));
free(p);
}
|
[
"#include <stdlib.h>",
"typedef struct X X;",
"struct X {\n int f;\n};"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 16
| 22
|
memcpy_002
|
pulse/memcpy.c
|
memcpy_to_null_bad
|
memcpy_to_null
|
void memcpy_to_null() {
X x;
X* p = NULL;
memcpy(p, &x, sizeof(X)); // crash
}
|
[
"#include <stdlib.h>",
"typedef struct X X;",
"struct X {\n int f;\n};"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
3
] |
[
27
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 24
| 28
|
memcpy_003
|
pulse/memcpy.c
|
memcpy_to_null_indirect_bad
|
memcpy_to_null_indirect
|
void memcpy_to_null_indirect() {
X x;
X* r;
X* p = NULL;
r = p;
memcpy(r, &x, sizeof(X)); // crash
}
|
[
"#include <stdlib.h>",
"typedef struct X X;",
"struct X {\n int f;\n};"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
5
] |
[
35
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,assigned,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 30
| 36
|
memcpy_004
|
pulse/memcpy.c
|
memcpy_from_null_bad
|
memcpy_from_null
|
void memcpy_from_null() {
X* src = NULL;
X* p = malloc(sizeof(X));
if (p) {
memcpy(p, src, sizeof(X)); // crash
free(p);
}
}
|
[
"#include <stdlib.h>",
"typedef struct X X;",
"struct X {\n int f;\n};"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
4
] |
[
42
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 38
| 45
|
memory_leak_001
|
pulse/memory_leak.c
|
malloc_no_free_bad
|
malloc_no_free
|
void malloc_no_free() { int* p = malloc(sizeof(p)); }
|
[
"#include <stdlib.h>"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
0
] |
[
9
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,allocated by `malloc` here,memory becomes unreachable here"
] |
memory_leak
| false
| 9
| 9
|
memory_leak_002
|
pulse/memory_leak.c
|
malloc_returned_ok
|
malloc_returned
|
int* malloc_returned() {
int* p = malloc(sizeof(p));
return p;
}
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 11
| 14
|
memory_leak_003
|
pulse/memory_leak.c
|
malloc_out_parameter_ok
|
malloc_out_parameter
|
void malloc_out_parameter(int** x) { *x = (int*)malloc(sizeof(int)); }
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 16
| 16
|
memory_leak_004
|
pulse/memory_leak.c
|
malloc_out_parameter_local_mutation_ok
|
malloc_out_parameter_local_mutation
|
void malloc_out_parameter_local_mutation(int** x) {
*x = (int*)malloc(sizeof(int));
x = NULL; // not visible from the outside
}
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 18
| 21
|
memory_leak_005
|
pulse/memory_leak.c
|
malloc_out_parameter_local_mutation_bad
|
malloc_out_parameter_local_mutation
|
void malloc_out_parameter_local_mutation(int** x) {
*x = (int*)malloc(sizeof(int));
*x = NULL;
}
|
[
"#include <stdlib.h>"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
3
] |
[
26
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,allocated by `malloc` here,memory becomes unreachable here"
] |
memory_leak
| false
| 23
| 26
|
memory_leak_006
|
pulse/memory_leak.c
|
malloc_then_free_ok
|
malloc_then_free
|
void malloc_then_free() {
int* p = malloc(sizeof(p));
if (p) {
*p = 5;
free(p);
}
}
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 28
| 34
|
memory_leak_007
|
pulse/memory_leak.c
|
create_p
|
create_p
|
int* create_p() {
int* p = malloc(sizeof(p));
return p;
}
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 36
| 39
|
memory_leak_008
|
pulse/memory_leak.c
|
malloc_interproc_no_free_bad
|
malloc_interproc_no_free
|
void malloc_interproc_no_free() { int* p = create_p(); }
|
[
"#include <stdlib.h>",
"int* create_p() {\n int* p = malloc(sizeof(p));\n return p;\n}\n"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
0
] |
[
41
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,when calling `create_p` here,allocated by `malloc` here,memory becomes unreachable here"
] |
memory_leak
| true
| 41
| 41
|
memory_leak_009
|
pulse/memory_leak.c
|
malloc_interproc_no_free_bad2
|
malloc_interproc_no_free_bad2
|
void malloc_interproc_no_free_bad2() {
int* p = malloc(sizeof(p));
int z = 3;
int y = 4;
int* q = p;
}
|
[
"#include <stdlib.h>"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
4
] |
[
47
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,allocated by `malloc` here,memory becomes unreachable here"
] |
memory_leak
| false
| 43
| 48
|
memory_leak_010
|
pulse/memory_leak.c
|
malloc_formal_leak_bad
|
malloc_formal_leak
|
void malloc_formal_leak(int* x) { x = (int*)malloc(sizeof(int*)); }
|
[
"#include <stdlib.h>"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
0
] |
[
50
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,allocated by `malloc` here,memory becomes unreachable here"
] |
memory_leak
| false
| 50
| 50
|
memory_leak_011
|
pulse/memory_leak.c
|
malloc_via_ptr
|
malloc_via_ptr
|
void* malloc_via_ptr(size_t size) {
void* ret = NULL;
if (size <= 0) {
return NULL;
}
ret = malloc_func(size);
return ret;
}
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 55
| 64
|
memory_leak_012
|
pulse/memory_leak.c
|
free_via_ptr
|
free_via_ptr
|
void free_via_ptr(void* x) { free_func(x); }
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 66
| 66
|
memory_leak_013
|
pulse/memory_leak.c
|
malloc_ptr_leak_bad
|
malloc_ptr_leak
|
void malloc_ptr_leak() { int* p = (int*)malloc_via_ptr(sizeof(int)); }
|
[
"#include <stdlib.h>",
"void* malloc_via_ptr(size_t size) {\n void* ret = NULL;\n\n if (size <= 0) {\n return NULL;\n }\n\n ret = malloc_func(size);\n return ret;\n}\n"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
0
] |
[
68
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,when calling `malloc_via_ptr` here,allocated by `malloc` here,memory becomes unreachable here"
] |
memory_leak
| true
| 68
| 68
|
memory_leak_014
|
pulse/memory_leak.c
|
malloc_ptr_no_check_leak_bad
|
malloc_ptr_no_check_leak
|
void malloc_ptr_no_check_leak() {
int* p = (int*)malloc_via_ptr(sizeof(int));
*p = 42;
}
|
[
"#include <stdlib.h>",
"void* malloc_via_ptr(size_t size) {\n void* ret = NULL;\n\n if (size <= 0) {\n return NULL;\n }\n\n ret = malloc_func(size);\n return ret;\n}\n"
] | true
|
[
"MEMORY_LEAK_C",
"NULLPTR_DEREFERENCE"
] |
[
2,
2
] |
[
72,
72
] |
[
"ERROR",
"ERROR"
] |
[
"allocation part of the trace starts here,when calling `malloc_via_ptr` here,allocated by `malloc` here,memory becomes unreachable here",
"in call to `malloc_via_ptr`,in call to `malloc (null case)` (modelled),is assigned to the null pointer,assigned,returned,return from call to `malloc_via_ptr`,assigned,invalid access occurs here"
] |
nullptr_dereference
| true
| 70
| 73
|
memory_leak_015
|
pulse/memory_leak.c
|
malloc_ptr_free_ok
|
malloc_ptr_free
|
void malloc_ptr_free() {
int* p = (int*)malloc_via_ptr(sizeof(int));
free(p);
}
|
[
"#include <stdlib.h>",
"void* malloc_via_ptr(size_t size) {\n void* ret = NULL;\n\n if (size <= 0) {\n return NULL;\n }\n\n ret = malloc_func(size);\n return ret;\n}\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 75
| 78
|
memory_leak_016
|
pulse/memory_leak.c
|
malloc_ptr_free_ptr_ok
|
malloc_ptr_free_ptr
|
void malloc_ptr_free_ptr() {
int* p = (int*)malloc_via_ptr(sizeof(int));
free_via_ptr(p);
}
|
[
"#include <stdlib.h>",
"void* malloc_via_ptr(size_t size) {\n void* ret = NULL;\n\n if (size <= 0) {\n return NULL;\n }\n\n ret = malloc_func(size);\n return ret;\n}\n",
"void free_via_ptr(void* x) { free_func(x); }\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 80
| 83
|
memory_leak_017
|
pulse/memory_leak.c
|
alias_ptr_free_ok
|
alias_ptr_free
|
void alias_ptr_free(int* out, int flag) {
int* y;
if (flag) {
y = (int*)malloc(sizeof(int));
} else {
y = out;
}
if (y && y != out) {
free(y);
}
}
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 85
| 95
|
memory_leak_018
|
pulse/memory_leak.c
|
report_leak_in_correct_line_bad
|
report_leak_in_correct_line
|
void report_leak_in_correct_line(int* x) {
x = (int*)malloc(sizeof(int));
if (x != NULL) {
return; // should report leak at this line
}
free(x);
}
|
[
"#include <stdlib.h>"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
2
] |
[
99
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,allocated by `malloc` here,memory becomes unreachable here"
] |
memory_leak
| false
| 97
| 103
|
memory_leak_019
|
pulse/memory_leak.c
|
realloc_wrapper
|
realloc_wrapper
|
void* realloc_wrapper(void* p, size_t size) { return realloc(p, size); }
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 105
| 105
|
memory_leak_020
|
pulse/memory_leak.c
|
realloc_free_ok
|
realloc_free
|
void realloc_free() {
int* p = (int*)malloc(sizeof(int));
int* q = realloc_wrapper(p, sizeof(int));
free(q);
}
|
[
"#include <stdlib.h>",
"void* realloc_wrapper(void* p, size_t size) { return realloc(p, size); }\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 107
| 111
|
memory_leak_021
|
pulse/memory_leak.c
|
realloc_no_free_bad
|
realloc_no_free
|
void realloc_no_free() {
int* p = (int*)malloc(sizeof(int));
int* q = realloc_wrapper(p, sizeof(int));
}
|
[
"#include <stdlib.h>",
"void* realloc_wrapper(void* p, size_t size) { return realloc(p, size); }\n"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
2
] |
[
115
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,when calling `realloc_wrapper` here,allocated by `realloc` here,memory becomes unreachable here"
] |
memory_leak
| true
| 113
| 116
|
memory_leak_022
|
pulse/memory_leak.c
|
realloc_no_check_bad
|
realloc_no_check
|
void realloc_no_check() {
int* p = (int*)malloc(sizeof(int));
int* q = realloc_wrapper(p, sizeof(int));
*q = 42;
free(q);
}
|
[
"#include <stdlib.h>",
"void* realloc_wrapper(void* p, size_t size) { return realloc(p, size); }\n"
] | true
|
[
"NULLPTR_DEREFERENCE",
"NULLPTR_DEREFERENCE"
] |
[
3,
3
] |
[
121,
121
] |
[
"ERROR",
"ERROR"
] |
[
"in call to `realloc_wrapper`,in call to `realloc (null case)` (modelled),is assigned to the null pointer,returned,return from call to `realloc_wrapper`,assigned,invalid access occurs here",
"in call to `malloc (null case)` (modelled),is assigned to the null pointer,assigned,in call to `realloc_wrapper`,in call to `realloc (null case)` (modelled),is assigned to the null pointer,returned,return from call to `realloc_wrapper`,assigned,invalid access occurs here"
] |
nullptr_dereference
| true
| 118
| 123
|
memory_leak_023
|
pulse/memory_leak.c
|
user_malloc_leak_bad
|
user_malloc_leak
|
void user_malloc_leak() { int* x = (int*)a_malloc(sizeof(int)); }
|
[
"#include <stdlib.h>"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
0
] |
[
130
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,allocated by `a_malloc (custom malloc)` here,memory becomes unreachable here"
] |
memory_leak
| false
| 130
| 130
|
memory_leak_024
|
pulse/memory_leak.c
|
test_config_options_1_ok
|
test_config_options_1
|
void test_config_options_1() {
int* p = (int*)malloc(sizeof(int));
int* q = my_realloc(p, sizeof(int));
my_free(q);
}
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 132
| 136
|
memory_leak_025
|
pulse/memory_leak.c
|
test_config_options_2_ok
|
test_config_options_2
|
void test_config_options_2() {
int* p = (int*)my_malloc(sizeof(int));
int* q = realloc(p, sizeof(int));
my_free(q);
}
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 138
| 142
|
memory_leak_026
|
pulse/memory_leak.c
|
test_config_options_no_free_bad
|
test_config_options_no_free
|
void test_config_options_no_free() {
int* p = (int*)my_malloc(sizeof(int));
int* q = my_realloc(p, sizeof(int));
}
|
[
"#include <stdlib.h>"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
2
] |
[
146
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,allocated by `my_realloc (custom realloc)` here,memory becomes unreachable here"
] |
memory_leak
| false
| 144
| 147
|
memory_leak_027
|
pulse/memory_leak.c
|
alloc_ref_counted_ok
|
alloc_ref_counted
|
int* alloc_ref_counted() {
struct ref_counted* p =
(struct ref_counted*)malloc(sizeof(struct ref_counted));
if (p) {
p->count = 1;
return &(p->data);
} else {
return NULL;
}
}
|
[
"#include <stdlib.h>",
"struct ref_counted {\n size_t count;\n int data;\n};"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 156
| 165
|
memory_leak_028
|
pulse/memory_leak.c
|
alloc_ref_counted_bad
|
alloc_ref_counted
|
int alloc_ref_counted() {
struct ref_counted* p =
(struct ref_counted*)malloc(sizeof(struct ref_counted));
if (p) {
p->count = 1;
p->data = 42;
return p->data;
} else {
return 0;
}
}
|
[
"#include <stdlib.h>",
"struct ref_counted {\n size_t count;\n int data;\n};"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
6
] |
[
174
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,allocated by `malloc` here,memory becomes unreachable here"
] |
memory_leak
| false
| 168
| 178
|
memory_leak_029
|
pulse/memory_leak.c
|
alloc_ref_counted_arith_ok
|
alloc_ref_counted_arith
|
void* alloc_ref_counted_arith(size_t size) {
int* p = (int*)malloc(size + sizeof(int));
if (p) {
// register count = 1 and point past the ref count
*p++ = 1;
}
return p;
}
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 182
| 189
|
memory_leak_030
|
pulse/memory_leak.c
|
return_malloc_deref_bad
|
return_malloc_deref
|
int return_malloc_deref() {
int* p = (int*)malloc(sizeof(int));
if (p) {
*p = 42;
return *p;
}
return 10;
}
|
[
"#include <stdlib.h>"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
4
] |
[
195
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,allocated by `malloc` here,memory becomes unreachable here"
] |
memory_leak
| false
| 191
| 198
|
memory_leak_031
|
pulse/memory_leak.c
|
mutual_recursion
|
mutual_recursion
|
void mutual_recursion(NODE* x) { mutual_recursion_2(x); }
|
[
"#include <stdlib.h>",
"typedef struct node_st {\n int* data;\n} NODE;",
"void mutual_recursion_2(NODE* x) { mutual_recursion(x); }\n"
] | true
|
[
"INFINITE_RECURSION"
] |
[
0
] |
[
206
] |
[
"WARNING"
] |
[
"`mutual_recursion` calls `mutual_recursion_2`,`mutual_recursion_2` makes a recursive call to `mutual_recursion` with the same argument values"
] |
other
| true
| 206
| 206
|
memory_leak_032
|
pulse/memory_leak.c
|
mutual_recursion_2
|
mutual_recursion_2
|
void mutual_recursion_2(NODE* x) { mutual_recursion(x); }
|
[
"#include <stdlib.h>",
"typedef struct node_st {\n int* data;\n} NODE;",
"void mutual_recursion(NODE* x) { mutual_recursion_2(x); }\n"
] | true
|
[
"INFINITE_RECURSION"
] |
[
0
] |
[
208
] |
[
"WARNING"
] |
[
"`mutual_recursion_2` calls `mutual_recursion`,`mutual_recursion` makes a recursive call to `mutual_recursion_2` with the same argument values"
] |
other
| true
| 208
| 208
|
memory_leak_033
|
pulse/memory_leak.c
|
interproc_mutual_recusion_leak
|
interproc_mutual_recusion_leak
|
void interproc_mutual_recusion_leak(NODE* x) {
int* d;
if (x->data == NULL) {
x->data = (int*)malloc(sizeof(int));
}
mutual_recursion(x);
}
|
[
"#include <stdlib.h>",
"typedef struct node_st {\n int* data;\n} NODE;",
"void mutual_recursion(NODE* x) { mutual_recursion_2(x); }\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 210
| 216
|
memory_leak_034
|
pulse/memory_leak.c
|
allocate_all_in_array
|
allocate_all_in_array
|
void allocate_all_in_array(int* array[]) {
for (int i = 0; i < 2; i++) {
array[i] = malloc(sizeof(int));
}
}
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 218
| 222
|
memory_leak_035
|
pulse/memory_leak.c
|
free_all_in_array
|
free_all_in_array
|
void free_all_in_array(int* array[]) {
for (int i = 0; i < 2; i++) {
free(array[i]);
}
}
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 224
| 228
|
memory_leak_036
|
pulse/memory_leak.c
|
alloc_then_free_all_in_array_ok
|
alloc_then_free_all_in_array
|
void alloc_then_free_all_in_array() {
int* array[2];
allocate_all_in_array(array);
free_all_in_array(array);
}
|
[
"#include <stdlib.h>",
"void allocate_all_in_array(int* array[]) {\n for (int i = 0; i < 2; i++) {\n array[i] = malloc(sizeof(int));\n }\n}\n",
"void free_all_in_array(int* array[]) {\n for (int i = 0; i < 2; i++) {\n free(array[i]);\n }\n}\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 230
| 234
|
memory_leak_037
|
pulse/memory_leak.c
|
allocate_42_in_array
|
allocate_42_in_array
|
void allocate_42_in_array(int* array[]) { array[42] = malloc(sizeof(int)); }
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 236
| 236
|
memory_leak_038
|
pulse/memory_leak.c
|
free_42_in_array
|
free_42_in_array
|
void free_42_in_array(int* array[]) { free(array[42]); }
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 238
| 238
|
memory_leak_039
|
pulse/memory_leak.c
|
alloc_then_free_42_in_array_ok
|
alloc_then_free_42_in_array
|
void alloc_then_free_42_in_array() {
int* array[64];
allocate_42_in_array(array);
free_42_in_array(array);
}
|
[
"#include <stdlib.h>",
"void allocate_42_in_array(int* array[]) { array[42] = malloc(sizeof(int)); }\n",
"void free_42_in_array(int* array[]) { free(array[42]); }\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 240
| 244
|
memory_leak_040
|
pulse/memory_leak.c
|
allocate_in_array
|
allocate_in_array
|
void allocate_in_array(int* array[], int i) { array[i] = malloc(sizeof(int)); }
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 246
| 246
|
memory_leak_041
|
pulse/memory_leak.c
|
free_in_array
|
free_in_array
|
void free_in_array(int* array[], int i) { free(array[i]); }
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 248
| 248
|
memory_leak_042
|
pulse/memory_leak.c
|
alloc_then_free_fixed_index_ok
|
alloc_then_free_fixed_index
|
void alloc_then_free_fixed_index() {
int* array[64];
allocate_in_array(array, 42);
free_in_array(array, 42);
}
|
[
"#include <stdlib.h>",
"void allocate_in_array(int* array[], int i) { array[i] = malloc(sizeof(int)); }\n",
"void free_in_array(int* array[], int i) { free(array[i]); }\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 250
| 254
|
memory_leak_043
|
pulse/memory_leak.c
|
alloc_then_free_parameter_array_ok
|
alloc_then_free_parameter_array
|
void alloc_then_free_parameter_array(int* array[], int i) {
allocate_in_array(array, i);
free_in_array(array, i);
}
|
[
"#include <stdlib.h>",
"void allocate_in_array(int* array[], int i) { array[i] = malloc(sizeof(int)); }\n",
"void free_in_array(int* array[], int i) { free(array[i]); }\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 256
| 259
|
memory_leak_044
|
pulse/memory_leak.c
|
alloc_then_free_at_index_ok
|
alloc_then_free_at_index
|
void alloc_then_free_at_index(int i) {
int* array[64];
allocate_in_array(array, i);
free_in_array(array, i);
}
|
[
"#include <stdlib.h>",
"void allocate_in_array(int* array[], int i) { array[i] = malloc(sizeof(int)); }\n",
"void free_in_array(int* array[], int i) { free(array[i]); }\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 261
| 265
|
memory_leak_more_001
|
pulse/memory_leak_more.c
|
simple_leak_bad
|
simple_leak
|
void simple_leak() {
int* p;
p = (int*)malloc(sizeof(int));
}
|
[
"#include <stdlib.h>",
"#include <string.h>"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
2
] |
[
13
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,allocated by `malloc` here,memory becomes unreachable here"
] |
memory_leak
| false
| 11
| 14
|
memory_leak_more_002
|
pulse/memory_leak_more.c
|
allocate
|
allocate
|
int* allocate() {
int* p = NULL;
do {
p = (int*)malloc(sizeof(int));
} while (p == NULL);
return p;
}
|
[
"#include <stdlib.h>",
"#include <string.h>"
] | true
|
[
"INFINITE_LOOP"
] |
[
2
] |
[
36
] |
[
"WARNING"
] |
[
"in loop"
] |
other
| false
| 34
| 40
|
memory_leak_more_003
|
pulse/memory_leak_more.c
|
leak_via_allocator_bad
|
leak_via_allocator
|
void leak_via_allocator() {
int* p;
p = allocate();
*p = 42;
}
|
[
"#include <stdlib.h>",
"#include <string.h>",
"int* allocate() {\n int* p = NULL;\n do {\n p = (int*)malloc(sizeof(int));\n } while (p == NULL);\n return p;\n}\n"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
3
] |
[
45
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,when calling `allocate` here,allocated by `malloc` here,memory becomes unreachable here"
] |
memory_leak
| true
| 42
| 46
|
memory_leak_more_004
|
pulse/memory_leak_more.c
|
return_memset_ok
|
return_memset
|
void* return_memset(size_t s) {
char* str = malloc(sizeof(s));
if (str) {
return memset(str, 0, s);
}
}
|
[
"#include <stdlib.h>",
"#include <string.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 48
| 53
|
memory_leak_more_005
|
pulse/memory_leak_more.c
|
conditional_last_instruction_bad
|
conditional_last_instruction
|
void conditional_last_instruction() {
int* p = malloc(sizeof(int));
if (0) {
free(p);
}
}
|
[
"#include <stdlib.h>",
"#include <string.h>"
] | true
|
[
"MEMORY_LEAK_C"
] |
[
2
] |
[
57
] |
[
"ERROR"
] |
[
"allocation part of the trace starts here,allocated by `malloc` here,memory becomes unreachable here"
] |
memory_leak
| false
| 55
| 60
|
memory_leak_more_006
|
pulse/memory_leak_more.c
|
compound_return_ok
|
compound_return
|
int* compound_return() {
return ({
int* p = malloc(sizeof(int));
p;
});
}
|
[
"#include <stdlib.h>",
"#include <string.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 62
| 67
|
nullptr_001
|
pulse/nullptr.c
|
malloc_no_check_bad
|
malloc_no_check
|
int* malloc_no_check() {
int* p = (int*)malloc(sizeof(int));
*p = 42;
return p;
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
2
] |
[
14
] |
[
"ERROR"
] |
[
"in call to `malloc (null case)` (modelled),is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 12
| 16
|
nullptr_002
|
pulse/nullptr.c
|
malloc_assert_ok
|
malloc_assert
|
void malloc_assert() {
int* p = (int*)malloc(sizeof(int));
assert(p);
*p = 42;
free(p);
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 18
| 23
|
nullptr_003
|
pulse/nullptr.c
|
create_null_path_ok
|
create_null_path
|
void create_null_path(int* p) {
if (p) {
*p = 32;
}
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 25
| 29
|
nullptr_004
|
pulse/nullptr.c
|
call_create_null_path_then_deref_unconditionally_ok
|
call_create_null_path_then_deref_unconditionally
|
void call_create_null_path_then_deref_unconditionally(int* p) {
create_null_path_ok(p);
*p = 52;
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>",
"void create_null_path_ok(int* p) {\n if (p) {\n *p = 32;\n }\n}\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 31
| 34
|
nullptr_005
|
pulse/nullptr.c
|
create_null_path2_bad_FN
|
create_null_path2_bad_FN
|
void create_null_path2_bad_FN(int* p) {
int* q = NULL;
if (p) {
*p = 32;
}
// arguably bogus to check p above but not here, but the above could
// also be macro-generated code so both reporting and not reporting
// are sort of justifiable
*p = 52;
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
8
] |
[
44
] |
[
"ERROR"
] |
[
"*** SUPPRESSED ***,source of the null value part of the trace starts here,assigned,is assigned to the null pointer,null pointer dereference part of the trace starts here,parameter `p` of create_null_path2_bad_FN,invalid access occurs here"
] |
nullptr_dereference
| false
| 36
| 45
|
nullptr_006
|
pulse/nullptr.c
|
nullptr_deref_young_bad
|
nullptr_deref_young
|
void nullptr_deref_young(int* x) {
int* vec[65] = {x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
x, x, x, x, x, x, x, x, x, x, x, x, x, NULL};
int p = *vec[64];
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
5
] |
[
65
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 60
| 66
|
nullptr_007
|
pulse/nullptr.c
|
malloc_free_ok
|
malloc_free
|
void malloc_free() {
int* p = (int*)malloc(sizeof(int));
free(p);
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 79
| 82
|
nullptr_008
|
pulse/nullptr.c
|
wrap_free
|
wrap_free
|
void wrap_free(void* p) { free(p); }
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 84
| 84
|
nullptr_009
|
pulse/nullptr.c
|
interproc_free_ok
|
interproc_free
|
void interproc_free() {
int* p = (int*)malloc(sizeof(int));
wrap_free(p);
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>",
"void wrap_free(void* p) { free(p); }\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 86
| 89
|
nullptr_010
|
pulse/nullptr.c
|
wrap_malloc
|
wrap_malloc
|
void wrap_malloc(int** x) {
*x = (int*)malloc(sizeof(int));
if (!*x) {
no_return();
}
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 93
| 98
|
nullptr_011
|
pulse/nullptr.c
|
call_no_return_good
|
call_no_return
|
void call_no_return() {
int* x = NULL;
wrap_malloc(&x);
*x = 5;
free(x);
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>",
"void wrap_malloc(int** x) {\n *x = (int*)malloc(sizeof(int));\n if (!*x) {\n no_return();\n }\n}\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 100
| 105
|
nullptr_012
|
pulse/nullptr.c
|
bug_after_malloc_result_test_bad
|
bug_after_malloc_result_test
|
void bug_after_malloc_result_test(int* x) {
x = (int*)malloc(sizeof(int));
if (x) {
int* y = NULL;
*y = 42;
}
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
4
] |
[
111
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 107
| 113
|
nullptr_013
|
pulse/nullptr.c
|
bug_after_abduction_bad
|
bug_after_abduction
|
void bug_after_abduction(int* x) {
*x = 42;
int* y = NULL;
*y = 42;
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
3
] |
[
118
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 115
| 119
|
nullptr_014
|
pulse/nullptr.c
|
bug_with_allocation_bad
|
bug_with_allocation
|
void bug_with_allocation(int* x) {
x = (int*)malloc(sizeof(int));
int* y = NULL;
*y = 42;
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
3
] |
[
124
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 121
| 125
|
nullptr_015
|
pulse/nullptr.c
|
null_alias_bad
|
null_alias
|
void null_alias(int* x) {
int* y = NULL;
x = (int*)malloc(sizeof(int*));
*x = 42;
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | true
|
[
"MEMORY_LEAK_C",
"NULLPTR_DEREFERENCE"
] |
[
3,
3
] |
[
130,
130
] |
[
"ERROR",
"ERROR"
] |
[
"allocation part of the trace starts here,allocated by `malloc` here,memory becomes unreachable here",
"in call to `malloc (null case)` (modelled),is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 127
| 131
|
nullptr_016
|
pulse/nullptr.c
|
dereference
|
dereference
|
void dereference(int* p) { int i = *p; }
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 133
| 133
|
nullptr_017
|
pulse/nullptr.c
|
several_dereferences_ok
|
several_dereferences
|
void several_dereferences(int* x, int* y, int* z) {
int* p = x;
*z = 52;
dereference(y);
*y = 42;
*x = 32;
*x = 777;
*y = 888;
*z = 999;
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>",
"void dereference(int* p) { int i = *p; }\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 135
| 144
|
nullptr_018
|
pulse/nullptr.c
|
report_correct_error_among_multiple_bad
|
report_correct_error_among_multiple
|
void report_correct_error_among_multiple() {
int* p = NULL;
// the trace should complain about the first access inside the callee
several_dereferences_ok(p, p, p);
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>",
"void several_dereferences_ok(int* x, int* y, int* z) {\n int* p = x;\n *z = 52;\n dereference(y);\n *y = 42;\n *x = 32;\n *x = 777;\n *y = 888;\n *z = 999;\n}\n"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
3
] |
[
149
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,assigned,when calling `several_dereferences_ok` here,parameter `z` of several_dereferences_ok,invalid access occurs here"
] |
nullptr_dereference
| true
| 146
| 150
|
nullptr_019
|
pulse/nullptr.c
|
unknown_is_functional_ok
|
unknown_is_functional
|
void unknown_is_functional() {
int* p = NULL;
if (unknown(10) != unknown(10)) {
*p = 42;
}
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 154
| 159
|
nullptr_020
|
pulse/nullptr.c
|
unknown_with_different_values_bad
|
unknown_with_different_values
|
void unknown_with_different_values() {
int* p = NULL;
if (unknown(32) != unknown(52)) {
*p = 42;
}
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
3
] |
[
164
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 161
| 166
|
nullptr_021
|
pulse/nullptr.c
|
unknown_conditional_dereference
|
unknown_conditional_dereference
|
void unknown_conditional_dereference(int x, int* p) {
if (unknown(x) == 999) {
*p = 42;
}
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 168
| 172
|
nullptr_022
|
pulse/nullptr.c
|
unknown_from_parameters_latent
|
unknown_from_parameters
|
void unknown_from_parameters(int x) {
unknown_conditional_dereference(x, NULL);
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>",
"void unknown_conditional_dereference(int x, int* p) {\n if (unknown(x) == 999) {\n *p = 42;\n }\n}\n"
] | true
|
[
"NULLPTR_DEREFERENCE_LATENT"
] |
[
1
] |
[
175
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,when calling `unknown_conditional_dereference` here,parameter `p` of unknown_conditional_dereference,invalid access occurs here"
] |
other
| true
| 174
| 176
|
nullptr_023
|
pulse/nullptr.c
|
random_non_functional_bad
|
random_non_functional
|
void random_non_functional() {
if (random() != random()) {
int* p = NULL;
*p = 42;
}
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
3
] |
[
182
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 179
| 184
|
nullptr_024
|
pulse/nullptr.c
|
random_modelled_bad
|
random_modelled
|
void random_modelled(int y) {
int x = random();
if (x == y) {
int* p = NULL;
*p = 42;
}
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
4
] |
[
190
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 186
| 192
|
nullptr_025
|
pulse/nullptr.c
|
arithmetic_weakness_ok
|
arithmetic_weakness
|
void arithmetic_weakness() {
int x = random();
int y = random();
if (x < y && x > y) {
int* p = NULL;
*p = 42;
}
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 194
| 201
|
nullptr_026
|
pulse/nullptr.c
|
no_invalidation_compare_to_NULL_bad
|
no_invalidation_compare_to_NULL
|
void no_invalidation_compare_to_NULL() {
int* p = unknown_int_pointer();
int x;
int* q = &x;
if (p == NULL) {
q = p;
}
*q = 42;
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | true
|
[
"COMPARED_TO_NULL_AND_DEREFERENCED"
] |
[
7
] |
[
212
] |
[
"ERROR"
] |
[
"compared to null here,in call to function `unknown_int_pointer` with no summary,assigned,was compared to null on line 209, column 7,assigned,invalid access occurs here"
] |
other
| false
| 205
| 213
|
nullptr_027
|
pulse/nullptr.c
|
incr_deref
|
incr_deref
|
void incr_deref(int* x, int* y) {
(*x)++;
(*y)++;
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 215
| 218
|
nullptr_028
|
pulse/nullptr.c
|
call_incr_deref_with_alias_bad
|
call_incr_deref_with_alias
|
void call_incr_deref_with_alias(void) {
int x = 0;
int* ptr = &x;
incr_deref(ptr, ptr);
if (x == 2) {
ptr = NULL;
}
x = *ptr;
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>",
"void incr_deref(int* x, int* y) {\n (*x)++;\n (*y)++;\n}\n"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
7
] |
[
227
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| true
| 220
| 228
|
nullptr_029
|
pulse/nullptr.c
|
call_incr_deref_with_alias_good
|
call_incr_deref_with_alias
|
void call_incr_deref_with_alias(void) {
int x = 0;
int* ptr = &x;
incr_deref(ptr, ptr);
if (x != 2) {
ptr = NULL;
}
x = *ptr;
}
|
[
"#include <assert.h>",
"#include <stdlib.h>",
"#include <stdnoreturn.h>",
"void incr_deref(int* x, int* y) {\n (*x)++;\n (*y)++;\n}\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 230
| 238
|
nullptr_more_001
|
pulse/nullptr_more.c
|
simple_null_pointer_bad
|
simple_null_pointer
|
int simple_null_pointer() {
struct Person* max = NULL;
return max->age;
}
|
[
"#include <stdlib.h>",
"struct Person {\n int age;\n int height;\n int weight;\n};"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
2
] |
[
18
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 16
| 19
|
nullptr_more_002
|
pulse/nullptr_more.c
|
get_age
|
get_age
|
int get_age(struct Person* who) { return who->age; }
|
[
"#include <stdlib.h>",
"struct Person {\n int age;\n int height;\n int weight;\n};"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 26
| 26
|
nullptr_more_003
|
pulse/nullptr_more.c
|
null_pointer_interproc_bad
|
null_pointer_interproc
|
int null_pointer_interproc() {
struct Person* joe = Person_create(32, 64, 140);
return get_age(joe);
}
|
[
"#include <stdlib.h>",
"struct Person {\n int age;\n int height;\n int weight;\n};",
"int get_age(struct Person* who) { return who->age; }\n"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
2
] |
[
30
] |
[
"ERROR"
] |
[
"in call to `Person_create`,is assigned to the null pointer,assigned,returned,return from call to `Person_create`,assigned,when calling `get_age` here,parameter `who` of get_age,invalid access occurs here"
] |
nullptr_dereference
| true
| 28
| 31
|
nullptr_more_004
|
pulse/nullptr_more.c
|
negation_in_conditional_ok
|
negation_in_conditional
|
int negation_in_conditional() {
int* x = NULL;
if (!x)
return 0;
else
return *x; // this never happens
}
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 33
| 39
|
nullptr_more_005
|
pulse/nullptr_more.c
|
null_pointer_with_function_pointer_bad
|
null_pointer_with_function_pointer
|
void null_pointer_with_function_pointer() {
int* (*fp)();
fp = return_null;
int* x = fp();
*x = 3;
}
|
[
"#include <stdlib.h>"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
4
] |
[
47
] |
[
"ERROR"
] |
[
"in call to `return_null`,is assigned to the null pointer,returned,return from call to `return_null`,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 43
| 48
|
nullptr_more_006
|
pulse/nullptr_more.c
|
exit_if_null_ok
|
exit_if_null
|
void exit_if_null(struct Person* htbl) {
if (!htbl)
exit(0);
int x = htbl->age;
}
|
[
"#include <stdlib.h>",
"struct Person {\n int age;\n int height;\n int weight;\n};"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 50
| 54
|
nullptr_more_007
|
pulse/nullptr_more.c
|
FPuseafterfree_no_check_for_null_after_realloc_bad
|
FPuseafterfree_no_check_for_null_after_realloc
|
void FPuseafterfree_no_check_for_null_after_realloc() {
int* p;
p = (int*)malloc(sizeof(int) * 5);
if (p) {
p[3] = 42;
}
int* q = (int*)realloc(p, sizeof(int) * 10);
if (!q)
free(p); // FP
q[7] = 0; // NULL dereference
free(q);
}
|
[
"#include <stdlib.h>"
] | true
|
[
"USE_AFTER_FREE",
"NULLPTR_DEREFERENCE"
] |
[
8,
9
] |
[
64,
65
] |
[
"ERROR",
"ERROR"
] |
[
"invalidation part of the trace starts here,allocated by call to `malloc` (modelled),assigned,was invalidated by call to `free()`,use-after-lifetime part of the trace starts here,allocated by call to `malloc` (modelled),assigned,invalid access occurs here",
"in call to `realloc (null case)` (modelled),is assigned to the null pointer,assigned,invalid access occurs here"
] |
nullptr_dereference
| false
| 56
| 67
|
nullptr_more_008
|
pulse/nullptr_more.c
|
assign
|
assign
|
void assign(int* p, int n) { *p = n; }
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 69
| 69
|
nullptr_more_009
|
pulse/nullptr_more.c
|
potentially_null_pointer_passed_as_argument_bad
|
potentially_null_pointer_passed_as_argument
|
void potentially_null_pointer_passed_as_argument() {
int* p = NULL;
p = (int*)malloc(sizeof(int));
assign(p, 42); // NULL dereference
free(p);
}
|
[
"#include <stdlib.h>",
"void assign(int* p, int n) { *p = n; }\n"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
3
] |
[
74
] |
[
"ERROR"
] |
[
"in call to `malloc (null case)` (modelled),is assigned to the null pointer,assigned,when calling `assign` here,parameter `p` of assign,invalid access occurs here"
] |
nullptr_dereference
| true
| 71
| 76
|
nullptr_more_010
|
pulse/nullptr_more.c
|
null_passed_as_argument_bad
|
null_passed_as_argument
|
void null_passed_as_argument() {
assign(NULL, 42); // NULL dereference
}
|
[
"#include <stdlib.h>",
"void assign(int* p, int n) { *p = n; }\n"
] | true
|
[
"NULLPTR_DEREFERENCE"
] |
[
1
] |
[
79
] |
[
"ERROR"
] |
[
"is assigned to the null pointer,when calling `assign` here,parameter `p` of assign,invalid access occurs here"
] |
nullptr_dereference
| true
| 78
| 80
|
nullptr_more_011
|
pulse/nullptr_more.c
|
allocated_pointer_passed_as_argument_ok
|
allocated_pointer_passed_as_argument
|
void allocated_pointer_passed_as_argument() {
int* p = NULL;
p = (int*)malloc(sizeof(int));
if (p) {
assign(p, 42);
free(p);
}
}
|
[
"#include <stdlib.h>",
"void assign(int* p, int n) { *p = n; }\n"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| true
| 82
| 89
|
nullptr_more_012
|
pulse/nullptr_more.c
|
unsafe_allocate
|
unsafe_allocate
|
int* unsafe_allocate() {
int* p = NULL;
p = (int*)malloc(sizeof(int));
return p;
}
|
[
"#include <stdlib.h>"
] | false
|
[] |
[] |
[] |
[] |
[] |
safe
| false
| 91
| 95
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.