Skip to content

Commit 9249c02

Browse files
committed
bail early when setting zero-length image source
the pointer can actually be null in this case which triggers a ubsan panic
1 parent ae4b113 commit 9249c02

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/Image.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ Image::SetSource(const Napi::CallbackInfo& info){
280280

281281
cairo_status_t
282282
Image::loadFromBuffer(uint8_t *buf, unsigned len) {
283+
if (len == 0) return CAIRO_STATUS_READ_ERROR;
284+
283285
uint8_t data[4] = {0};
284286
memcpy(data, buf, (len < 4 ? len : 4) * sizeof(uint8_t));
285287

0 commit comments

Comments
 (0)