Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Source/FreeImage/PluginTARGA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,13 @@ loadRLE(FIBITMAP*& dib, int width, int height, FreeImageIO* io, fi_handle handle
if (remaining_size < height) {
throw FI_MSG_ERROR_CORRUPTED;
}
const long sz = (remaining_size / height);
long sz = (remaining_size / height);

// Ensure the cache is at least one pixel wide to prevent
// out-of-bounds reads when getBytes(file_pixel_size) is called.
if (sz < file_pixel_size) {
sz = file_pixel_size;
}

// ...and allocate cache of this size (yields good results)
IOCache cache(io, handle, sz);
Expand Down