0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

src: check for empty maybe local

Using ToLocalChecked on MaybeLocal without verifying it's empty
can lead to unattempted crash.

PR-URL: https://github.com/nodejs/node/pull/32339
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Xavier Stouder 2020-03-18 08:46:40 +01:00 committed by Anna Henningsen
parent 1b1c2993a5
commit 191fb3c2f2
No known key found for this signature in database
GPG Key ID: A94130F0BFC8EBE9

View File

@ -516,7 +516,8 @@ void UDPWrap::DoSend(const FunctionCallbackInfo<Value>& args, int family) {
// construct uv_buf_t array
for (size_t i = 0; i < count; i++) {
Local<Value> chunk = chunks->Get(env->context(), i).ToLocalChecked();
Local<Value> chunk;
if (!chunks->Get(env->context(), i).ToLocal(&chunk)) return;
size_t length = Buffer::Length(chunk);