Limit possible lottie parameters

This commit is contained in:
Isaac 2023-12-13 23:28:40 +04:00
parent b5029991f2
commit 21354c783d
2 changed files with 7 additions and 2 deletions

View File

@ -592,9 +592,9 @@ public final class AnimatedStickerDirectFrameSource: AnimatedStickerFrameSource
return nil return nil
} }
self.animation = animation self.animation = animation
let frameCount = Int(animation.frameCount) let frameCount = max(1, Int(animation.frameCount))
self.frameCount = frameCount self.frameCount = frameCount
self.frameRate = Int(animation.frameRate) self.frameRate = max(1, Int(animation.frameRate))
self.cache = cachePathPrefix.flatMap { cachePathPrefix in self.cache = cachePathPrefix.flatMap { cachePathPrefix in
AnimatedStickerDirectFrameSourceCache(queue: queue, pathPrefix: cachePathPrefix, width: width, height: height, frameCount: frameCount, fitzModifier: fitzModifier, useHardware: useMetalCache) AnimatedStickerDirectFrameSourceCache(queue: queue, pathPrefix: cachePathPrefix, width: width, height: height, frameCount: frameCount, fitzModifier: fitzModifier, useHardware: useMetalCache)

View File

@ -49,7 +49,9 @@
} }
_frameCount = (int32_t)_animation->totalFrame(); _frameCount = (int32_t)_animation->totalFrame();
_frameCount = MAX(1, _frameCount);
_frameRate = (int32_t)_animation->frameRate(); _frameRate = (int32_t)_animation->frameRate();
_frameRate = MAX(1, _frameRate);
size_t width = 0; size_t width = 0;
size_t height = 0; size_t height = 0;
@ -59,6 +61,9 @@
return nil; return nil;
} }
width = MAX(1, width);
height = MAX(1, height);
_dimensions = CGSizeMake(width, height); _dimensions = CGSizeMake(width, height);
if ((_frameRate > 360) || _animation->duration() > 9.0) { if ((_frameRate > 360) || _animation->duration() > 9.0) {