Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Unified Diff: test/cctest/cctest.cc

Issue 1934633002: Avoid reliance on undefined malloc(0) behavior. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/cctest.cc
diff --git a/test/cctest/cctest.cc b/test/cctest/cctest.cc
index 58a5829bab3e4fe518a140d2018d959dc7cb615c..5681f704e15de94662516efabc3c0499bf579989 100644
--- a/test/cctest/cctest.cc
+++ b/test/cctest/cctest.cc
@@ -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(); }
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698