Skip to content

Commit

Permalink
Merge pull request sosy-lab#1221 from smackers/fix-malloc-zero
Browse files Browse the repository at this point in the history
Passing size of 0 to malloc leads to assertion violation
  • Loading branch information
dbeyer authored Nov 11, 2020
2 parents b713275 + da438e2 commit f89d213
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion c/aws-c-common/aws_string_eq_byte_buf_harness.i
Original file line number Diff line number Diff line change
Expand Up @@ -6860,7 +6860,7 @@ struct aws_string *ensure_string_is_allocated_nondet_length() {

struct aws_string *ensure_string_is_allocated_bounded_length(size_t max_size) {
size_t len = nondet_uint64_t();
assume_abort_if_not(len < max_size);
assume_abort_if_not(0 < len && len < max_size);
return ensure_string_is_allocated(len);
}

Expand Down
5 changes: 3 additions & 2 deletions c/aws-c-common/aws_string_new_from_array_harness.i
Original file line number Diff line number Diff line change
Expand Up @@ -9460,10 +9460,11 @@ struct aws_string *aws_string_clone_or_reuse(struct aws_allocator *allocator, co
}
void aws_string_new_from_array_harness() {

size_t alloc_size;
size_t alloc_size = nondet_size_t();
assume_abort_if_not(alloc_size > 0);
uint8_t *array = bounded_malloc(alloc_size);
struct aws_allocator *allocator = can_fail_allocator();
size_t reported_size;
size_t reported_size = nondet_size_t();


assume_abort_if_not(reported_size <= alloc_size);
Expand Down

0 comments on commit f89d213

Please sign in to comment.