diff --git a/Userland/Libraries/LibGfx/JPEGLoader.cpp b/Userland/Libraries/LibGfx/JPEGLoader.cpp index 21f78c6cd6..4984b3db11 100644 --- a/Userland/Libraries/LibGfx/JPEGLoader.cpp +++ b/Userland/Libraries/LibGfx/JPEGLoader.cpp @@ -194,6 +194,9 @@ struct JPEGLoadingContext { StartOfFrame frame; u8 hsample_factor { 0 }; u8 vsample_factor { 0 }; + u8 spectral_selection_start {}; + u8 spectral_selection_end {}; + u8 successive_approximation {}; Vector components; RefPtr bitmap; u16 dc_restart_interval { 0 }; @@ -565,17 +568,17 @@ static ErrorOr read_start_of_scan(AK::SeekableStream& stream, JPEGLoadingC } } - u8 spectral_selection_start = TRY(stream.read_value()); - u8 spectral_selection_end = TRY(stream.read_value()); - u8 successive_approximation = TRY(stream.read_value()); + context.spectral_selection_start = TRY(stream.read_value()); + context.spectral_selection_end = TRY(stream.read_value()); + context.successive_approximation = TRY(stream.read_value()); // The three values should be fixed for baseline JPEGs utilizing sequential DCT. - if (spectral_selection_start != 0 || spectral_selection_end != 63 || successive_approximation != 0) { + if (context.spectral_selection_start != 0 || context.spectral_selection_end != 63 || context.successive_approximation != 0) { dbgln_if(JPEG_DEBUG, "{}: ERROR! Start of Selection: {}, End of Selection: {}, Successive Approximation: {}!", TRY(stream.tell()), - spectral_selection_start, - spectral_selection_end, - successive_approximation); + context.spectral_selection_start, + context.spectral_selection_end, + context.successive_approximation); return Error::from_string_literal("Spectral selection is not [0,63] or successive approximation is not null"); } return {};