mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-04 00:25:17 +00:00
Limit image size the app tries to read.
This will prevent some OOM crashes.
This commit is contained in:
@@ -56,6 +56,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#endif // OS_MAC_OLD
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr auto kImageAreaLimit = 6'016 * 3'384;
|
||||
|
||||
App::LaunchState _launchState = App::Launched;
|
||||
|
||||
HistoryView::Element *hoveredItem = nullptr,
|
||||
@@ -331,6 +334,13 @@ namespace App {
|
||||
reader.setAutoTransform(true);
|
||||
#endif // OS_MAC_OLD
|
||||
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();
|
||||
if (!fmt.isEmpty()) *format = fmt;
|
||||
if (!reader.read(&result)) {
|
||||
|
Reference in New Issue
Block a user