summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libnsbmp.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libnsbmp.c b/src/libnsbmp.c
index 1b28167..b4747f6 100644
--- a/src/libnsbmp.c
+++ b/src/libnsbmp.c
@@ -708,11 +708,14 @@ static bmp_result bmp_decode_rgb(bmp_image *bmp, uint8_t **start, int bytes)
cur_byte = *data++;
}
idx = (cur_byte >> bit_shifts[bit++]) & bit_mask;
- if (idx >= bmp->colours)
- return BMP_DATA_ERROR;
- scanline[x] = bmp->colour_table[idx];
- if ((bmp->limited_trans) && (scanline[x] == bmp->transparent_index))
- scanline[x] = bmp->trans_colour;
+ if (idx < bmp->colours) {
+ /* ensure colour table index is in bounds */
+ scanline[x] = bmp->colour_table[idx];
+ if ((bmp->limited_trans) &&
+ (scanline[x] == bmp->transparent_index)) {
+ scanline[x] = bmp->trans_colour;
+ }
+ }
}
}
*start = data;