[test] Fix UBSan failure

UBSan starts complaining about a nullptr destination in memcpy after
https://crrev.com/c/2691828.
This CL fixes the error by not copying if there is nothing to copy.

R=nicohartmann@chromium.org

No-Try: true
No-Tree-Checks: true
Change-Id: I2c941b37d26931d6c2253bc3bb2c0aa659d4cb71
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2690605
Commit-Queue: Nico Hartmann <nicohartmann@chromium.org>
Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72690}
This commit is contained in:
Clemens Backes 2021-02-12 12:17:34 +01:00 committed by Commit Bot
parent e5cf754b67
commit 587e7163cd

View File

@ -100,9 +100,11 @@ class CSignatureOf : public CSignature {
static_assert( static_assert(
std::is_same<decltype(*reps_), decltype(*param_types.data())>::value, std::is_same<decltype(*reps_), decltype(*param_types.data())>::value,
"type mismatch, cannot memcpy"); "type mismatch, cannot memcpy");
if (kParamCount > 0) {
memcpy(storage_ + kReturnCount, param_types.data(), memcpy(storage_ + kReturnCount, param_types.data(),
sizeof(*storage_) * kParamCount); sizeof(*storage_) * kParamCount);
} }
}
private: private:
static constexpr size_t kReturnCount = static constexpr size_t kReturnCount =