SkinImage: enforce that height/width must be positive

This commit is contained in:
Dylan K. Taylor 2020-01-22 14:58:36 +00:00
parent b8d44ff162
commit 8184a6b114

View File

@ -35,6 +35,9 @@ class SkinImage{
private $data;
public function __construct(int $height, int $width, string $data){
if($height < 0 or $width < 0){
throw new \InvalidArgumentException("Height and width cannot be negative");
}
if(($expected = $height * $width * 4) !== ($actual = strlen($data))){
throw new \InvalidArgumentException("Data should be exactly $expected bytes, got $actual bytes");
}