From cca7834e6718c6ff64da42ed5e9770880a3e8ff6 Mon Sep 17 00:00:00 2001 From: whowillbellthecat Date: Mon, 13 Sep 2021 22:24:40 +0600 Subject: fix: out-of-bounds access when bg not in color map --- image.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/image.c b/image.c index e4adc06..6f37f44 100644 --- a/image.c +++ b/image.c @@ -205,6 +205,10 @@ bool img_load_gif(img_t *img, const fileinfo_t *file) ptr = data = (DATA32*) emalloc(sizeof(DATA32) * sw * sh); cmap = gif->Image.ColorMap ? gif->Image.ColorMap : gif->SColorMap; + if (bg >= cmap->ColorCount) { + err = true; + break; + } r = cmap->Colors[bg].Red; g = cmap->Colors[bg].Green; b = cmap->Colors[bg].Blue; -- cgit v1.2.3