Fix crash when converting invalid image to JPEG
This commit is contained in:
parent
a6c8329a68
commit
6ee95f9529
1 changed files with 2 additions and 0 deletions
|
@ -291,6 +291,8 @@ v8::Local<v8::Value> NativeImage::ToBitmap(mate::Arguments* args) {
|
|||
v8::Local<v8::Value> NativeImage::ToJPEG(v8::Isolate* isolate, int quality) {
|
||||
std::vector<unsigned char> output;
|
||||
gfx::JPEG1xEncodedDataFromImage(image_, quality, &output);
|
||||
if (output.empty())
|
||||
return node::Buffer::New(isolate, 0).ToLocalChecked();
|
||||
return node::Buffer::Copy(
|
||||
isolate,
|
||||
reinterpret_cast<const char*>(&output.front()),
|
||||
|
|
Loading…
Reference in a new issue