fuzzers: Don't call data() on empty std::vector

UBSAN takes objection to this.

Fixed: chromium:1230344
Fixed: chromium:1230346
Fixed: chromium:1230372
Fixed: chromium:1230439
Fixed: chromium:1230457
Change-Id: I351bca06911f2e87f929f08d2aa78a1d8d43d296
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58399
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Ben Clayton 2021-07-19 09:33:19 +00:00 committed by Tint LUCI CQ
parent 595b0547d4
commit cdcec6d08c
1 changed files with 5 additions and 3 deletions

View File

@ -50,9 +50,11 @@ class Reader {
return {};
}
std::vector<T> out(count);
memcpy(out.data(), data_, count * sizeof(T));
data_ += count * sizeof(T);
size_ -= count * sizeof(T);
if (!out.empty()) {
memcpy(out.data(), data_, count * sizeof(T));
data_ += count * sizeof(T);
size_ -= count * sizeof(T);
}
return out;
}