Don't crash on corrupt animated images

This commit is contained in:
Nicolas Werner 2022-05-04 08:26:03 +02:00
parent d839204640
commit e4f8d32a72
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -70,6 +70,7 @@ MxcAnimatedImage::startDownload()
if (!self)
return;
try {
if (buffer.isOpen()) {
movie.stop();
movie.setDevice(nullptr);
@ -79,13 +80,17 @@ MxcAnimatedImage::startDownload()
if (encryptionInfo) {
QByteArray ba = device.readAll();
std::string temp(ba.constData(), ba.size());
temp = mtx::crypto::to_string(mtx::crypto::decrypt_file(temp, encryptionInfo.value()));
temp =
mtx::crypto::to_string(mtx::crypto::decrypt_file(temp, encryptionInfo.value()));
buffer.setData(temp.data(), temp.size());
} else {
buffer.setData(device.readAll());
}
buffer.open(QIODevice::ReadOnly);
buffer.reset();
} catch (const std::exception &e) {
nhlog::net()->error("Failed to setup animated image buffer: {}", e.what());
}
QTimer::singleShot(0, this, [this, mimeType] {
nhlog::ui()->info(