-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: fix vector subscript out of range #18460
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests pass: https://ci.nodejs.org/job/node-test-commit-light/196/
This seems to solve the problem. Thanks for the quick fix @apapirovski!
It would be great if someone else from @nodejs/platform-windows could confirm that this indeed fixes the issue before fast-tracking this. |
@@ -1002,7 +1002,9 @@ MaybeLocal<Value> InternalMakeCallback(Environment* env, | |||
} else { | |||
std::vector<Local<Value>> args(1 + argc); | |||
args[0] = callback; | |||
std::copy(&argv[0], &argv[argc], &args[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could replace &args[1]
with &args.data()[1]
to get rid of the conditional.
(It's legal to create a pointer that points one element beyond the array as long as you don't dereference it - which won't happen if argc == 0
because there won't be elements to copy.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better: replace it with args.begin() + 1
, since std::copy
works with iterators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, updated now. Thanks for the feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use either mine or @bnoordhuis's suggestion to avoid the conditional.
e2d9232
to
a9b76c7
Compare
Landed in 332b56c |
Needs to land if we backport #18291 |
PR-URL: nodejs#18460 Fixes: nodejs#18459 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Nikolai Vavilov <vvnicholas@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe>
It appears that #18291 broke debug builds on Windows. This should resolve the issue.
@tniessen is currently running a test. If anyone else can try a Windows debug build with this patch applied, that would be appreciated.
Fixes: #18459
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
src