LibGfx: Fail JPEG decode instead of asserting on bogus start-of-scan

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28628
This commit is contained in:
Andreas Kling 2020-12-23 19:22:15 +01:00
parent 0fc8561029
commit cd046fae44
Notes: sideshowbarker 2024-07-19 00:39:21 +09:00

View file

@ -552,7 +552,10 @@ static bool read_start_of_scan(InputMemoryStream& stream, JPGLoadingContext& con
auto it = context.components.find(component_id);
if (it != context.components.end()) {
component = &it->value;
ASSERT(i == component->serial_id);
if (i != component->serial_id) {
dbgln("JPEG decode failed (i != component->serial_id)");
return false;
}
} else {
#ifdef JPG_DEBUG
dbg() << stream.offset() << String::format(": Unsupported component id: %i!", component_id);