Skip to content

Commit

Permalink
Fix potential null-deref and infinite loop (libjxl#4052)
Browse files Browse the repository at this point in the history
  • Loading branch information
eustas authored Jan 9, 2025
1 parent 23d6823 commit 2cf8dfc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/jxl/encode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ JxlEncoderOutputProcessorWrapper::GetBuffer(size_t min_size,
return JxlOutputProcessorBuffer(user_buffer, size, 0, this);
}
}
} else {
} else if (avail_out_ != nullptr) {
if (min_size + additional_size < *avail_out_) {
internal_buffers_.emplace(position_, InternalBuffer(memory_manager_));
has_buffer_ = true;
Expand Down Expand Up @@ -208,7 +208,7 @@ jxl::Status JxlEncoderOutputProcessorWrapper::CopyOutput(
JXL_RETURN_IF_ERROR(SetAvailOut(&next_out, &avail_out));
if (avail_out == 0) {
size_t offset = next_out - output.data();
output.resize(output.size() * 2);
output.resize(std::max<size_t>(64, output.size() * 2));
next_out = output.data() + offset;
avail_out = output.size() - offset;
}
Expand Down

0 comments on commit 2cf8dfc

Please sign in to comment.