Skip to content

Commit

Permalink
crypto: make malloc failure check cross-platform
Browse files Browse the repository at this point in the history
`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]>
  • Loading branch information
Trott authored and mhdawson committed Sep 6, 2016
1 parent a00ccb0 commit ed640ae
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
2 changes: 1 addition & 1 deletion src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5368,7 +5368,7 @@ class RandomBytesRequest : public AsyncWrap {
error_(0),
size_(size),
data_(static_cast<char*>(node::Malloc(size))) {
if (data() == nullptr)
if (data() == nullptr && size > 0)
FatalError("node::RandomBytesRequest()", "Out of Memory");
Wrap(object, this);
}
Expand Down
5 changes: 0 additions & 5 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ed640ae

Please sign in to comment.