mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-18 00:38:31 +00:00
[compiler-rt] FuzzedDataProvider: do not call memcpy on empty vector.
Summary: Some versions of memcpy mark pointer arguments as __nonnull, that triggers UBSan errors even when the length passed is 0. Reviewers: manojgupta, metzman Subscribers: dberris, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71031 [compiler-rt] FDP: assert that num_bytes_to_consume == 0 when size == 0.
This commit is contained in:
parent
b89ba5f939
commit
a44ef027eb
@ -263,6 +263,12 @@ class FuzzedDataProvider {
|
||||
// which seems to be a natural choice for other implementations as well.
|
||||
// To increase the odds even more, we also call |shrink_to_fit| below.
|
||||
std::vector<T> result(size);
|
||||
if (size == 0) {
|
||||
if (num_bytes_to_consume != 0)
|
||||
abort();
|
||||
return result;
|
||||
}
|
||||
|
||||
std::memcpy(result.data(), data_ptr_, num_bytes_to_consume);
|
||||
Advance(num_bytes_to_consume);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user