Commit 791c0400 authored by mbrandy's avatar mbrandy Committed by Commit bot

Avoid reliance on undefined malloc(0) behavior.

AIX returns NULL rather than a valid heap address.

TEST=cctest/test-run-wasm-module/Run_WasmModule_CallAdd_rev
R=titzer@chromium.org, jochen@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/1934633002
Cr-Commit-Position: refs/heads/master@{#35913}
parent 5b519033
......@@ -136,10 +136,12 @@ static void PrintTestList(CcTest* current) {
class CcTestArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
virtual void* Allocate(size_t length) {
void* data = AllocateUninitialized(length);
void* data = AllocateUninitialized(length == 0 ? 1 : length);
return data == NULL ? data : memset(data, 0, length);
}
virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
virtual void* AllocateUninitialized(size_t length) {
return malloc(length == 0 ? 1 : length);
}
virtual void Free(void* data, size_t length) { free(data); }
// TODO(dslomov): Remove when v8:2823 is fixed.
virtual void Free(void* data) { UNREACHABLE(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment