From 21354c783df8738b488e3753d3506909775d78e5 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Wed, 13 Dec 2023 23:28:40 +0400 Subject: [PATCH] Limit possible lottie parameters --- .../Sources/AnimatedStickerFrameSource.swift | 4 ++-- submodules/rlottie/LottieInstance.mm | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/submodules/AnimatedStickerNode/Sources/AnimatedStickerFrameSource.swift b/submodules/AnimatedStickerNode/Sources/AnimatedStickerFrameSource.swift index 9d815f9921..81aae9de5b 100644 --- a/submodules/AnimatedStickerNode/Sources/AnimatedStickerFrameSource.swift +++ b/submodules/AnimatedStickerNode/Sources/AnimatedStickerFrameSource.swift @@ -592,9 +592,9 @@ public final class AnimatedStickerDirectFrameSource: AnimatedStickerFrameSource return nil } self.animation = animation - let frameCount = Int(animation.frameCount) + let frameCount = max(1, Int(animation.frameCount)) self.frameCount = frameCount - self.frameRate = Int(animation.frameRate) + self.frameRate = max(1, Int(animation.frameRate)) self.cache = cachePathPrefix.flatMap { cachePathPrefix in AnimatedStickerDirectFrameSourceCache(queue: queue, pathPrefix: cachePathPrefix, width: width, height: height, frameCount: frameCount, fitzModifier: fitzModifier, useHardware: useMetalCache) diff --git a/submodules/rlottie/LottieInstance.mm b/submodules/rlottie/LottieInstance.mm index 1d40bc2aab..4989491f50 100755 --- a/submodules/rlottie/LottieInstance.mm +++ b/submodules/rlottie/LottieInstance.mm @@ -49,7 +49,9 @@ } _frameCount = (int32_t)_animation->totalFrame(); + _frameCount = MAX(1, _frameCount); _frameRate = (int32_t)_animation->frameRate(); + _frameRate = MAX(1, _frameRate); size_t width = 0; size_t height = 0; @@ -59,6 +61,9 @@ return nil; } + width = MAX(1, width); + height = MAX(1, height); + _dimensions = CGSizeMake(width, height); if ((_frameRate > 360) || _animation->duration() > 9.0) {