Use fixed size buffer for RLE bmps DO NOT MERGE
Cherry-pick of b3b24538e02ead0c3f5bc528818982475890efd6
An RLE bmp reports how many bytes it should contain. This number may be
incorrect, or it may be a very large number. Previously, we buffered
all bytes in a single allocation. Instead, use a fixed size buffer and
only read what fits into the buffer. We already have code to refill the
buffer if there is more data, so rely on that to keep reading.
Choose an arbitrary size for the buffer. It is larger than the maximum
possible number of bytes we need to read at once.
Add a test with a test image that reports a very large number for
the number of bytes it should contain. With the old method, we would
allocate 4 gigs of memory to decode this image, which is unnecessary
and may result in OOM.
Commit-Queue: Leon Scroggins <email@example.com>
Reviewed-by: Matt Sarett <firstname.lastname@example.org>
(cherry picked from commit 318e3505ac2436c62ec19fd27ebe9f8e7d174544)
5 files changed