src: Malloc/Calloc size 0 returns non-null pointer
Checklist
-
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines
Affected core subsystem(s)
crypto
Description of change
crypto.pbkdf2() with empty password and/or salt causes a fatal error in Node.js 6.6.0. It did not in 6.5.0. The problematic change is a00ccb0f. We still need to review other changes in that change set, but this is a test and fix for the specific issue reported in https://github.com/nodejs/node/issues/8571.
The problem is that malloc(0)
may return NULL on some platforms. So
do not report out-of-memory error unless malloc
was passed a number
greater than 0
.