LibGfx/JPEG: Don't call add_ac if not necessary

Calling it was harmless as add_ac iterates over the spectral selection,
hence it won't do anything if not needed. However, this patch remains
useful as it prevents dereferencing the iterator returned by find, in
case the AC table isn't defined yet. This case happens with SOF2 images
and is (pretty harmless as read only but still) undefined behavior.
This commit is contained in:
Lucas CHOLLET 2023-02-27 22:54:27 -05:00 committed by Linus Groh
parent 1926a86336
commit 18064fdb92
Notes: sideshowbarker 2024-07-17 05:09:48 +09:00

View file

@ -443,7 +443,8 @@ static ErrorOr<void> build_macroblocks(JPEGLoadingContext& context, Vector<Macro
if (context.current_scan.spectral_selection_start == 0)
TRY(add_dc(context, block, scan_component));
TRY(add_ac(context, block, scan_component));
if (context.current_scan.spectral_selection_end != 0)
TRY(add_ac(context, block, scan_component));
}
}
}