From 9b30ee69f023b2d0ea26c3cec1afb4270e7a6ca5 Mon Sep 17 00:00:00 2001 From: "likai.123" <471633877@qq.com> Date: Mon, 4 Dec 2023 13:21:03 +0800 Subject: [PATCH] fix crash --- LookinDemo/LookinCustomInfoDemo/Podfile.lock | 8 ++++---- Src/Main/Server/Category/CALayer+LookinServer.m | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/LookinDemo/LookinCustomInfoDemo/Podfile.lock b/LookinDemo/LookinCustomInfoDemo/Podfile.lock index b46a6af..512bdd4 100644 --- a/LookinDemo/LookinCustomInfoDemo/Podfile.lock +++ b/LookinDemo/LookinCustomInfoDemo/Podfile.lock @@ -1,6 +1,6 @@ PODS: - - LookinServer/Core (1.2.4) - - LookinServer/Swift (1.2.4): + - LookinServer/Core (1.2.5) + - LookinServer/Swift (1.2.5): - LookinServer/Core DEPENDENCIES: @@ -11,8 +11,8 @@ EXTERNAL SOURCES: :path: "../../" SPEC CHECKSUMS: - LookinServer: 00c7588043ed8e7ab64ce55b9fb747e51371ad06 + LookinServer: 6805292e8d2ff9ddfcfaa9357fc5c1f277c90afd PODFILE CHECKSUM: 46caada19d34f471f9e44165d96af39e799fd091 -COCOAPODS: 1.13.0 +COCOAPODS: 1.11.3 diff --git a/Src/Main/Server/Category/CALayer+LookinServer.m b/Src/Main/Server/Category/CALayer+LookinServer.m index 2bb55cb..e76fd4a 100644 --- a/Src/Main/Server/Category/CALayer+LookinServer.m +++ b/Src/Main/Server/Category/CALayer+LookinServer.m @@ -76,7 +76,8 @@ - (UIImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { } CGSize contextSize = self.frame.size; - if (contextSize.width <= 0 || contextSize.height <= 0) { + if (contextSize.width <= 0 || contextSize.height <= 0 || contextSize.width > 20000 || contextSize.height > 20000) { + NSLog(@"LookinServer - Failed to capture screenshot. Invalid context size: %@ x %@", @(contextSize.width), @(contextSize.height)); return nil; } UIGraphicsBeginImageContextWithOptions(contextSize, NO, renderScale); @@ -122,7 +123,11 @@ - (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { }]; CGSize contextSize = self.frame.size; - NSAssert(contextSize.width > 0 && contextSize.height > 0, @""); + if (contextSize.width <= 0 || contextSize.height <= 0 || contextSize.width > 20000 || contextSize.height > 20000) { + NSLog(@"LookinServer - Failed to capture screenshot. Invalid context size: %@ x %@", @(contextSize.width), @(contextSize.height)); + return nil; + } + UIGraphicsBeginImageContextWithOptions(contextSize, NO, renderScale); CGContextRef context = UIGraphicsGetCurrentContext(); if (self.lks_hostView && !self.lks_hostView.lks_isChildrenViewOfTabBar) {