From 15e2f0aa05a5326ae6b032ca2a335bd9e494d618 Mon Sep 17 00:00:00 2001 From: Darragh Coy Date: Thu, 5 Aug 2021 15:08:47 -0700 Subject: [PATCH] Sprite::setScaleY: fix a potential crash on iOS if the sprite has no texture assigned. Need to add a null check for a bit of Metal specific code. --- cocos/2d/CCSprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index eb20451354bf..fc81479a674a 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -1347,7 +1347,7 @@ void Sprite::setScaleX(float scaleX) void Sprite::setScaleY(float scaleY) { #ifdef CC_USE_METAL - if(_texture->isRenderTarget()) + if (_texture && _texture->isRenderTarget()) scaleY = std::abs(scaleY); #endif Node::setScaleY(scaleY);