File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ This release notably changes to using N-API. 🎉
32
32
* Changed PNG consts to static properties of Canvas class
33
33
### Added
34
34
* Added string tags to support class detection
35
+ * Throw Cairo errors in canvas.toBuffer()
35
36
### Fixed
36
37
* Fix a case of use-after-free. (#2229 )
37
38
* Fix usage of garbage value by filling the allocated memory entirely with zeros if it's not modified. (#2229 )
Original file line number Diff line number Diff line change @@ -382,7 +382,15 @@ Canvas::ToBuffer(const Napi::CallbackInfo& info) {
382
382
closure = static_cast <SvgBackend*>(backend ())->closure ();
383
383
}
384
384
385
- cairo_surface_finish (surface ());
385
+ cairo_surface_t *surf = surface ();
386
+ cairo_surface_finish (surf);
387
+
388
+ cairo_status_t status = cairo_surface_status (surf);
389
+ if (status != CAIRO_STATUS_SUCCESS) {
390
+ Napi::Error::New (env, cairo_status_to_string (status)).ThrowAsJavaScriptException ();
391
+ return env.Undefined ();
392
+ }
393
+
386
394
return Napi::Buffer<uint8_t >::Copy (env, &closure->vec [0 ], closure->vec .size ());
387
395
}
388
396
You can’t perform that action at this time.
0 commit comments