crypto: fixup bug in keygen error handling

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/36779
Refs: https://github.com/nodejs/node/pull/36729
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
James M Snell committed 2021-01-11 10:38:58 -08:00
1 parent a4fce32eab
commit b4378aa38a
1 file changed
+4 -2
+4 -2
View File
@@ -94,13 +94,15 @@ function generateKeyPairSync(type, options) {
}
function handleError(ret) {
if (ret === undefined)
if (ret == null)
return; // async
const [err, [publicKey, privateKey]] = ret;
const [err, keys] = ret;
if (err !== undefined)
throw err;
const [publicKey, privateKey] = keys;
// If no encoding was chosen, return key objects instead.
return {
publicKey: wrapKey(publicKey, PublicKeyObject),