From 6e0921140efb8895eb98efa99438fff23df2a726 Mon Sep 17 00:00:00 2001 From: daywalker-dev <144274661+daywalker-dev@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:58:45 -0600 Subject: [PATCH] helpers: fix jpeg and webp OOM error (#401) * Update Jpeg.cpp * Update Webp.cpp --- src/helpers/Jpeg.cpp | 1 + src/helpers/Webp.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/helpers/Jpeg.cpp b/src/helpers/Jpeg.cpp index c9ad08d..3616744 100644 --- a/src/helpers/Jpeg.cpp +++ b/src/helpers/Jpeg.cpp @@ -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); diff --git a/src/helpers/Webp.cpp b/src/helpers/Webp.cpp index c42047f..6941502 100644 --- a/src/helpers/Webp.cpp +++ b/src/helpers/Webp.cpp @@ -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);