Resolve GIMP segfault from accessing memory past end of pixbuf

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/2684

GIMP segfaults while switching themes between dark and gray and inputting Ctrl-O
to open a file. This is because p advances past end of pixbuf in pixbuf-render.c
compute_hint() with num_channels = 3 (no alpha). This is resolved by fixing the
if statement to only check for alpha, thereby advancing p, if there is an alpha
channel.
This commit is contained in:
Nam Nguyen
2020-05-01 21:55:49 +00:00
parent 29103cdc3c
commit d1b21ff159

View File

@@ -603,7 +603,7 @@ compute_hint (GdkPixbuf *pixbuf,
if (r != *(p++) ||
g != *(p++) ||
b != *(p++) ||
(n_channels != 4 && a != *(p++)))
(n_channels == 4 && a != *(p++)))
{
hints &= ~THEME_CONSTANT_ROWS;
if (!(hints & THEME_MISSING))