1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-31 09:31:53 +02:00

Throw exception on exceeding frame count

This commit is contained in:
Oliver Vogel
2024-01-15 10:05:22 +01:00
parent f9355c4344
commit dc7dc5f5ab

View File

@@ -7,6 +7,7 @@ use ImagickException;
use Iterator;
use Intervention\Image\Interfaces\CoreInterface;
use Intervention\Image\Exceptions\AnimationException;
use Intervention\Image\Exceptions\RuntimeException;
use Intervention\Image\Interfaces\CollectionInterface;
use Intervention\Image\Interfaces\FrameInterface;
@@ -89,6 +90,10 @@ class Core implements CoreInterface, Iterator
*/
public function slice(int $offset, ?int $length = null): CollectionInterface
{
if ($offset >= $this->count()) {
throw new RuntimeException('Offset exceeds the maximum value.');
}
$allowed_indexes = [];
$length = is_null($length) ? $this->count() : $length;
for ($i = $offset; $i < $offset + $length; $i++) {