Error when given an invalid image file

This commit is contained in:
Ske
2019-11-03 13:56:05 +01:00
parent 8d003da091
commit 0cdd99d195
2 changed files with 2 additions and 0 deletions

View File

@@ -62,6 +62,7 @@ namespace PluralKit.Bot
// Parse the image header in a worker
var stream = await response.Content.ReadAsStreamAsync();
var image = await Task.Run(() => Image.Identify(stream));
if (image == null) throw Errors.AvatarInvalid;
if (image.Width > Limits.AvatarDimensionLimit || image.Height > Limits.AvatarDimensionLimit) // Check image size
throw Errors.AvatarDimensionsTooLarge(image.Width, image.Height);
}