Skip to content

Commit

Permalink
[win] Check that the source color references a valid index in the pal…
Browse files Browse the repository at this point in the history
…ette when converting 8bpp images

This avoids crashing the program when converting a decoded malformed BMP (i.e. references palette indexes that don't exist).
  • Loading branch information
martincapello committed May 3, 2024
1 parent a3a90d6 commit dc8a30a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clip_win_wic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ bool decode(std::vector<GUID> decoderCLSIDs,
for (int y = 0; y < spec.height; ++y) {
char* dst_x = dst;
for (int x = 0; x < spec.width; ++x, dst_x+=spec.bits_per_pixel/8, ++src) {
*((uint32_t*)dst_x) = colors[*src];
*((uint32_t*)dst_x) = (*src < numcolors ? colors[*src] : 0);
}
dst += spec.bytes_per_row;
}
Expand Down

0 comments on commit dc8a30a

Please sign in to comment.