Fix crash on invalid data in local cache.

This commit is contained in:
John Preston 2022-05-02 15:36:34 +04:00
parent 276fe2169a
commit 39a02e649d
1 changed files with 8 additions and 5 deletions

View File

@ -150,14 +150,17 @@ DocumentData *Document::readFromStreamHelper(
}
}
const auto storage = std::get_if<StorageFileLocation>(
&thumb->file().data);
if ((stream.status() != QDataStream::Ok)
|| (!dc && !access)
|| !thumb
|| !videoThumb
|| (thumb->valid()
&& (!storage || !storage->isDocumentThumbnail()))) {
|| !videoThumb) {
stream.setStatus(QDataStream::ReadCorruptData);
return nullptr;
}
const auto storage = std::get_if<StorageFileLocation>(
&thumb->file().data);
if (thumb->valid()
&& (!storage || !storage->isDocumentThumbnail())) {
stream.setStatus(QDataStream::ReadCorruptData);
// We can't convert legacy thumbnail location to modern, because
// size letter ('s' or 'm') is lost, it was not saved in legacy.