Skip to content

Commit

Permalink
Passing size of 0 to malloc leads to assertion violation
Browse files Browse the repository at this point in the history
This commit avoids the situation where size of 0 can be
passed to malloc. I think it does not alter the spirit
of the benchmark.
  • Loading branch information
zvonimir committed Nov 10, 2020
1 parent 64b907c commit da438e2
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 da438e2

Please sign in to comment.