From ed640ae4cb3ca4a40311dc6fec62bfd87efec4cf Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 30 Aug 2016 23:18:26 -0700 Subject: [PATCH] crypto: make malloc failure check cross-platform `malloc(0)` may return NULL on some platforms. Do not report out-of-memory error unless `malloc` was passed a number greater than `0`. PR-URL: https://github.com/nodejs/node/pull/8352 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Fedor Indutny Reviewed-By: Michael Dawson --- src/node_crypto.cc | 2 +- test/parallel/parallel.status | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 6df6dbb85e..8e66be9849 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -5368,7 +5368,7 @@ class RandomBytesRequest : public AsyncWrap { error_(0), size_(size), data_(static_cast(node::Malloc(size))) { - if (data() == nullptr) + if (data() == nullptr && size > 0) FatalError("node::RandomBytesRequest()", "Out of Memory"); Wrap(object, this); } diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 604a5b2424..f2536b6b68 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -27,11 +27,6 @@ test-debug-signal-cluster : PASS,FLAKY test-fs-watch-enoent : FAIL, PASS test-fs-watch-encoding : FAIL, PASS -# being worked under https://github.com/nodejs/node/pull/7564 -test-async-wrap-post-did-throw : PASS, FLAKY -test-async-wrap-throw-from-callback : PASS, FLAKY -test-crypto-random : PASS, FLAKY - #being worked under https://github.com/nodejs/node/issues/7973 test-stdio-closed : PASS, FLAKY