Fix a possible leak when IsProgressiveJpeg gets invalid data
This commit is contained in:
parent
3fea35ff19
commit
2cd253208d
1 changed files with 5 additions and 4 deletions
|
|
@ -1277,6 +1277,10 @@ bool IsProgressiveJpeg(const QByteArray &bytes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
jpeg_create_decompress(&info);
|
jpeg_create_decompress(&info);
|
||||||
|
const auto guard = gsl::finally([&] {
|
||||||
|
jpeg_destroy_decompress(&info);
|
||||||
|
});
|
||||||
|
|
||||||
jpeg_mem_src(
|
jpeg_mem_src(
|
||||||
&info,
|
&info,
|
||||||
reinterpret_cast<const unsigned char*>(bytes.data()),
|
reinterpret_cast<const unsigned char*>(bytes.data()),
|
||||||
|
|
@ -1285,10 +1289,7 @@ bool IsProgressiveJpeg(const QByteArray &bytes) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto result = (info.progressive_mode > 0);
|
return (info.progressive_mode > 0);
|
||||||
jpeg_destroy_decompress(&info);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Images
|
} // namespace Images
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue