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 authored and Anna Henningsen committed 2020-03-30 19:18:00 +02:00
1 parent 13377a0f0f
commit aa282276ec
1 file changed
+2 -1
+2 -1
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);