lib/imlib: Fix raw stream buffer size check.

Check frame dimensions as well as total image size
top scale the image if needed.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit is contained in:
iabdalkader 2025-09-21 16:26:55 +02:00
parent 7a7788a03a
commit 552f4ada8e

View File

@ -305,7 +305,7 @@ void framebuffer_update_preview(image_t *src) {
// Down-scale the frame (if necessary) and send the raw frame. // Down-scale the frame (if necessary) and send the raw frame.
dst.size = src->bpp; dst.size = src->bpp;
dst.pixfmt = src->pixfmt; dst.pixfmt = src->pixfmt;
if (image_size(&dst) <= available_size) { if (src->w <= fb->raw_w && src->h <= fb->raw_h && image_size(&dst) <= available_size) {
memcpy(dst.pixels, src->pixels, image_size(src)); memcpy(dst.pixels, src->pixels, image_size(src));
} else { } else {
float scale = IM_MIN((fb->raw_w / (float) src->w), float scale = IM_MIN((fb->raw_w / (float) src->w),