Add safe checks around use of QImageReader (#3736)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
kornes
2022-05-28 11:48:31 +00:00
committed by GitHub
parent 135f914b38
commit efcfb19187
3 changed files with 35 additions and 12 deletions
+12 -2
View File
@@ -204,8 +204,18 @@ void TwitchBadges::loadEmoteImage(const QString &name, ImagePtr image,
buffer.open(QIODevice::ReadOnly);
QImageReader reader(&buffer);
QImage image;
if (reader.imageCount() == 0 || !reader.read(&image))
if (!reader.canRead() || reader.size().isEmpty())
{
return Failure;
}
QImage image = reader.read();
if (image.isNull())
{
return Failure;
}
if (reader.imageCount() <= 0)
{
return Failure;
}