Skip to content

Commit ed640ae

Browse files
Trottmhdawson
authored andcommitted
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: #8352 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent a00ccb0 commit ed640ae

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

src/node_crypto.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -5368,7 +5368,7 @@ class RandomBytesRequest : public AsyncWrap {
53685368
error_(0),
53695369
size_(size),
53705370
data_(static_cast<char*>(node::Malloc(size))) {
5371-
if (data() == nullptr)
5371+
if (data() == nullptr && size > 0)
53725372
FatalError("node::RandomBytesRequest()", "Out of Memory");
53735373
Wrap(object, this);
53745374
}

test/parallel/parallel.status

-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ test-debug-signal-cluster : PASS,FLAKY
2727
test-fs-watch-enoent : FAIL, PASS
2828
test-fs-watch-encoding : FAIL, PASS
2929

30-
# being worked under https://github.com/nodejs/node/pull/7564
31-
test-async-wrap-post-did-throw : PASS, FLAKY
32-
test-async-wrap-throw-from-callback : PASS, FLAKY
33-
test-crypto-random : PASS, FLAKY
34-
3530
#being worked under https://github.com/nodejs/node/issues/7973
3631
test-stdio-closed : PASS, FLAKY
3732

0 commit comments

Comments
 (0)