Add size check for large images.

This commit is contained in:
Pale Moon
2016-09-22 22:08:16 +02:00
committed by roytam1
parent 73a54610ab
commit 2e44e0589f
+5
View File
@@ -411,6 +411,11 @@ ImageEncoder::ExtractDataInternal(const nsAString& aType,
imgStream = do_QueryInterface(aEncoder);
}
} else {
CheckedInt32 requiredBytes = CheckedInt32(aSize.width) * CheckedInt32(aSize.height) * 4;
if (MOZ_UNLIKELY(!requiredBytes.isValid())) {
return NS_ERROR_INVALID_ARG;
}
// no context, so we have to encode an empty image
// note that if we didn't have a current context, the spec says we're
// supposed to just return transparent black pixels of the canvas