helpers: fix jpeg and webp OOM error (#401)

* Update Jpeg.cpp

* Update Webp.cpp
This commit is contained in:
daywalker-dev 2024-07-05 14:58:45 -06:00 committed by GitHub
parent 29420ddb6c
commit 6e0921140e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View file

@ -66,6 +66,7 @@ cairo_surface_t* JPEG::createSurfaceFromJPEG(const std::filesystem::path& path)
jpeg_read_scanlines(&decompressStruct, &rowRead, 1);
}
cairo_surface_flush(cairoSurface);
cairo_surface_mark_dirty(cairoSurface);
cairo_surface_set_mime_data(cairoSurface, CAIRO_MIME_TYPE_JPEG, (const unsigned char*)imageRawData, fileInfo.st_size, free, imageRawData);
jpeg_finish_decompress(&decompressStruct);

View file

@ -74,6 +74,7 @@ cairo_surface_t* WEBP::createSurfaceFromWEBP(const std::filesystem::path& path)
return nullptr;
}
cairo_surface_flush(cairoSurface);
cairo_surface_mark_dirty(cairoSurface);
cairo_surface_set_mime_data(cairoSurface, CAIRO_MIME_TYPE_PNG, (const unsigned char*)imageRawData, fileInfo.st_size, free, imageRawData);