diff --git a/src/smalloc.cc b/src/smalloc.cc index 97ae293b4bcd80..57ea97f2aca20e 100644 --- a/src/smalloc.cc +++ b/src/smalloc.cc @@ -314,8 +314,10 @@ void Alloc(Environment* env, char* data = static_cast(malloc(length)); if (data == nullptr) { - FatalError("node::smalloc::Alloc(v8::Handle, size_t," - " v8::ExternalArrayType)", "Out Of Memory"); + FatalError("node::smalloc::Alloc(node::Environment*, " + " v8::Handle, size_t, v8::ExternalArrayType)", + "Out Of Memory"); + UNREACHABLE(); } Alloc(env, obj, data, length, type); @@ -394,7 +396,14 @@ void Alloc(Environment* env, length *= type_size; - char* data = new char[length]; + char* data = static_cast(malloc(length)); + if (data == nullptr) { + FatalError("node::smalloc::Alloc(node::Environment*, " + " v8::Handle, size_t, node::FreeCallback," + " void*, v8::ExternalArrayType)", "Out Of Memory"); + UNREACHABLE(); + } + Alloc(env, obj, data, length, fn, hint, type); }