mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
src,buffer: evaluate THROW_AND_RETURN_IF_OOB() expression only once
There's no need to evaluate the expression passed into the macro more than once. Fixes: https://github.com/nodejs/node/issues/41935 Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: https://github.com/nodejs/node/pull/41945 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
1 parent
6db686710e
commit
5edad38328
1 file changed
+3
-2
+3
-2
@@ -41,8 +41,9 @@
|
||||
|
||||
#define THROW_AND_RETURN_IF_OOB(r) \
|
||||
do { \
|
||||
if ((r).IsNothing()) return; \
|
||||
if (!(r).FromJust()) \
|
||||
Maybe<bool> m = (r); \
|
||||
if (m.IsNothing()) return; \
|
||||
if (!m.FromJust()) \
|
||||
return node::THROW_ERR_OUT_OF_RANGE(env, "Index out of range"); \
|
||||
} while (0) \
|
||||
|
||||
|
||||
Reference in new issue
Block a user