Skip to content

Commit 047d4de

Browse files
RaisinTenbengl
authored andcommitted
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: #41935 Signed-off-by: Darshan Sen <[email protected]> PR-URL: #41945 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 0cc1a27 commit 047d4de

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/node_buffer.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141

4242
#define THROW_AND_RETURN_IF_OOB(r) \
4343
do { \
44-
if ((r).IsNothing()) return; \
45-
if (!(r).FromJust()) \
44+
Maybe<bool> m = (r); \
45+
if (m.IsNothing()) return; \
46+
if (!m.FromJust()) \
4647
return node::THROW_ERR_OUT_OF_RANGE(env, "Index out of range"); \
4748
} while (0) \
4849

0 commit comments

Comments
 (0)