Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/jpegli/decode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ void jpegli_save_markers(j_decompress_ptr cinfo, int marker_code,
unsigned int length_limit) {
// TODO(szabadka) Limit our memory usage by taking into account length_limit.
jpeg_decomp_master* m = cinfo->master;
if (marker_code < 0xe0) {
if (marker_code < 0xe0 || marker_code > 0xff) {
JPEGLI_ERROR("jpegli_save_markers: invalid marker code %d", marker_code);
}
m->markers_to_save_[marker_code - 0xe0] = 1;
Expand Down
12 changes: 12 additions & 0 deletions lib/jpegli/error_handling_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,18 @@ TEST(DecoderErrorHandlingTest, MinimalSuccess) {
jpegli_destroy_decompress(&cinfo);
}

TEST(DecoderErrorHandlingTest, InvalidSaveMarkersCode) {
jpeg_decompress_struct cinfo = {};
const auto try_catch_block = [&]() -> bool {
ERROR_HANDLER_SETUP(jpegli);
jpegli_create_decompress(&cinfo);
jpegli_save_markers(&cinfo, 0x100, 0xffff);
return true;
};
EXPECT_FALSE(try_catch_block());
jpegli_destroy_decompress(&cinfo);
}

TEST(DecoderErrorHandlingTest, NoSource) {
jpeg_decompress_struct cinfo = {};
const auto try_catch_block = [&]() -> bool {
Expand Down
Loading