Fix a possible leak when IsProgressiveJpeg gets invalid data

This commit is contained in:
Ilya Fedin 2023-01-02 07:56:27 +04:00 committed by John Preston
parent 3fea35ff19
commit 2cd253208d

View file

@ -1277,6 +1277,10 @@ bool IsProgressiveJpeg(const QByteArray &bytes) {
}
jpeg_create_decompress(&info);
const auto guard = gsl::finally([&] {
jpeg_destroy_decompress(&info);
});
jpeg_mem_src(
&info,
reinterpret_cast<const unsigned char*>(bytes.data()),
@ -1285,10 +1289,7 @@ bool IsProgressiveJpeg(const QByteArray &bytes) {
return false;
}
const auto result = (info.progressive_mode > 0);
jpeg_destroy_decompress(&info);
return result;
return (info.progressive_mode > 0);
}
} // namespace Images