Skip to content

Commit d1149a7

Browse files
committed
bflibrary: Improved error support in PNG palette retrieval
1 parent 73e8a4c commit d1149a7

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

bflibrary/src/general/gpng.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,12 @@ TbResult LbPngRead(FILE *img_fh, ubyte *out_buffer,
9898
if ((color_type == PNG_COLOR_TYPE_PALETTE) && (bit_depth <= 8)) {
9999
// If the file uses colour palette, get it
100100
png_colorp palette;
101+
u32 ret;
101102
int num;
102103

103-
png_get_PLTE(png, info, &palette, &num);
104+
ret = png_get_PLTE(png, info, &palette, &num);
105+
if (ret != PNG_INFO_PLTE)
106+
goto err;
104107
palette_from_png(pal, palette, num);
105108
} else {
106109
// Other file formats are not supported

0 commit comments

Comments
 (0)