From bbbd149ba3868a412b81021a005933f7dad8dfbb Mon Sep 17 00:00:00 2001 From: Jacob Boerema Date: Mon, 10 Jul 2023 14:18:36 -0400 Subject: [PATCH] plug-ins: fix possible integer overflow on large images in jigsaw Make sure we use gsize for intermediate results to not get integer overflow on large image sizes. This still is not ideal, but better than a crash, since we may (try to) allocate a very large block of memory, which we should eventually fix by looping over smaller size buffers. --- plug-ins/common/jigsaw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plug-ins/common/jigsaw.c b/plug-ins/common/jigsaw.c index ec3e251f77..c2fc8c26db 100644 --- a/plug-ins/common/jigsaw.c +++ b/plug-ins/common/jigsaw.c @@ -560,7 +560,7 @@ jigsaw (GObject *config, bytes = babl_format_get_bytes_per_pixel (format); /* setup image buffer */ - buffer_size = bytes * width * height; + buffer_size = (gsize) bytes * width * height; buffer = g_new (guchar, buffer_size); gegl_buffer_get (gegl_buffer, GEGL_RECTANGLE (0, 0, width, height), 1.0,