Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkokke <spam@rowdy.dk>2021-09-14 14:33:48 +0300
committerNode.js GitHub Bot <github-bot@iojs.org>2021-09-30 17:41:38 +0300
commitb66c2e150c068f670464ea1ffca1072ff46ca59f (patch)
treea5590f8e5bb78c1ef457550a5482732c8b51a0e3 /src/udp_wrap.cc
parentafb4ad6135ea137de1435830db20fdd6cb48e0c8 (diff)
src: fix time-of-use vs time-of-check "bugs"
Refs: https://github.com/nodejs/node/pull/40128 PR-URL: https://github.com/nodejs/node/pull/40128 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/udp_wrap.cc')
-rw-r--r--src/udp_wrap.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc
index 10c92358cc7..f068995e9b0 100644
--- a/src/udp_wrap.cc
+++ b/src/udp_wrap.cc
@@ -371,13 +371,17 @@ void UDPWrap::Disconnect(const FunctionCallbackInfo<Value>& args) {
#define X(name, fn) \
void UDPWrap::name(const FunctionCallbackInfo<Value>& args) { \
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder()); \
+ if (wrap == nullptr) { \
+ args.GetReturnValue().Set(UV_EBADF); \
+ return; \
+ } \
Environment* env = wrap->env(); \
CHECK_EQ(args.Length(), 1); \
int flag; \
if (!args[0]->Int32Value(env->context()).To(&flag)) { \
return; \
} \
- int err = wrap == nullptr ? UV_EBADF : fn(&wrap->handle_, flag); \
+ int err = fn(&wrap->handle_, flag); \
args.GetReturnValue().Set(err); \
}