Skip to content

Commit

Permalink
don't allow empty frames (libjxl#1427)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsneyers authored May 19, 2022
1 parent a444260 commit f2ea6da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/jxl/fields_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ TEST(FieldsTest, TestRoundtripSize) {
// Ensure all values can be reached by the encoding.
TEST(FieldsTest, TestCropRect) {
CodecMetadata metadata;
for (int32_t i = -1000; i < 19000; ++i) {
for (int32_t i = -999; i < 19000; ++i) {
FrameHeader f(&metadata);
f.custom_size_or_origin = true;
f.frame_origin.x0 = i;
Expand Down
5 changes: 5 additions & 0 deletions lib/jxl/frame_header.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ Status FrameHeader::VisitFields(Visitor* JXL_RESTRICT visitor) {
// Frame size
JXL_QUIET_RETURN_IF_ERROR(visitor->U32(enc, 0, &frame_size.xsize));
JXL_QUIET_RETURN_IF_ERROR(visitor->U32(enc, 0, &frame_size.ysize));
if (custom_size_or_origin &&
(frame_size.xsize == 0 || frame_size.ysize == 0)) {
return JXL_FAILURE(
"Invalid crop dimensions for frame: zero width or height");
}
int32_t image_xsize = default_xsize();
int32_t image_ysize = default_ysize();
if (frame_type == FrameType::kRegularFrame ||
Expand Down

0 comments on commit f2ea6da

Please sign in to comment.