Skip to content

Commit

Permalink
Fix invalid memory access on small images.
Browse files Browse the repository at this point in the history
Calling butteraugli::Mask was sufficient to cause problems for small
images.
  • Loading branch information
robryk authored and jyrkialakuijala committed Jan 25, 2017
1 parent 921e748 commit 5de9ad8
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions guetzli/processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -854,9 +854,13 @@ bool Process(const Params& params, ProcessStats* stats,
if (stats == nullptr) {
stats = &dummy_stats;
}
ButteraugliComparator comparator(jpg.width, jpg.height, rgb,
params.butteraugli_target, stats);
bool ok = ProcessJpegData(params, jpg, &comparator, &out, stats);
std::unique_ptr<ButteraugliComparator> comparator;
if (jpg.width >= 32 && jpg.height >= 32) {
comparator.reset(
new ButteraugliComparator(jpg.width, jpg.height, rgb,
params.butteraugli_target, stats));
}
bool ok = ProcessJpegData(params, jpg, comparator.get(), &out, stats);
*jpg_out = out.jpeg_data;
return ok;
}
Expand All @@ -874,9 +878,13 @@ bool Process(const Params& params, ProcessStats* stats,
if (stats == nullptr) {
stats = &dummy_stats;
}
ButteraugliComparator comparator(jpg.width, jpg.height, rgb,
params.butteraugli_target, stats);
bool ok = ProcessJpegData(params, jpg, &comparator, &out, stats);
std::unique_ptr<ButteraugliComparator> comparator;
if (jpg.width >= 32 && jpg.height >= 32) {
comparator.reset(
new ButteraugliComparator(jpg.width, jpg.height, rgb,
params.butteraugli_target, stats));
}
bool ok = ProcessJpegData(params, jpg, comparator.get(), &out, stats);
*jpg_out = out.jpeg_data;
return ok;
}
Expand Down

0 comments on commit 5de9ad8

Please sign in to comment.