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
fix: don't crash when nativeImage.createFromBuffer() is called with invalid buffer #17344
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.
Is there a more idiomatic way of saying "get the first argument as a buffer"? I see e.g. https://github.com/electron/electron/blob/master/atom/common/native_mate_converters/v8_value_converter.cc#L245
@nornagon I've seen this in other APIs to validate if an instance is a Buffer void Clipboard::WriteBuffer(const std::string& format,
const v8::Local<v8::Value> buffer,
mate::Arguments* args) {
if (!node::Buffer::HasInstance(buffer)) {
args->ThrowError("buffer must be a node Buffer");
return;
}
...
} An abstraction could be created, but we have to make sure it does not copy the data unnecessarily. |
670deda
to
1b46d2e
Compare
@nornagon
|
Release Notes Persisted
|
I have automatically backported this PR to "3-1-x", please check out #17372 |
I have automatically backported this PR to "4-0-x", please check out #17373 |
I have automatically backported this PR to "5-0-x", please check out #17374 |
Description of Change
Adds missing
node::Buffer::HasInstance(buffer)
check before using thebuffer
.Checklist
npm test
passesRelease Notes
Notes: Fixed crash when
nativeImage.createFromBuffer()
is called with invalidbuffer
.