mirror of https://github.com/procxx/kepka.git
Limit image size the app tries to read.
This will prevent some OOM crashes.
This commit is contained in:
parent
d5b8fc703e
commit
2c0b852dad
|
@ -56,6 +56,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#endif // OS_MAC_OLD
|
#endif // OS_MAC_OLD
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
constexpr auto kImageAreaLimit = 6'016 * 3'384;
|
||||||
|
|
||||||
App::LaunchState _launchState = App::Launched;
|
App::LaunchState _launchState = App::Launched;
|
||||||
|
|
||||||
HistoryView::Element *hoveredItem = nullptr,
|
HistoryView::Element *hoveredItem = nullptr,
|
||||||
|
@ -331,6 +334,13 @@ namespace App {
|
||||||
reader.setAutoTransform(true);
|
reader.setAutoTransform(true);
|
||||||
#endif // OS_MAC_OLD
|
#endif // OS_MAC_OLD
|
||||||
if (animated) *animated = reader.supportsAnimation() && reader.imageCount() > 1;
|
if (animated) *animated = reader.supportsAnimation() && reader.imageCount() > 1;
|
||||||
|
if (!reader.canRead()) {
|
||||||
|
return QImage();
|
||||||
|
}
|
||||||
|
const auto imageSize = reader.size();
|
||||||
|
if (imageSize.width() * imageSize.height() > kImageAreaLimit) {
|
||||||
|
return QImage();
|
||||||
|
}
|
||||||
QByteArray fmt = reader.format();
|
QByteArray fmt = reader.format();
|
||||||
if (!fmt.isEmpty()) *format = fmt;
|
if (!fmt.isEmpty()) *format = fmt;
|
||||||
if (!reader.read(&result)) {
|
if (!reader.read(&result)) {
|
||||||
|
|
Loading…
Reference in New Issue