From 324ab63844e2c42024e9fb7f8fdde234330f1bad Mon Sep 17 00:00:00 2001 From: jmb462 Date: Tue, 16 Mar 2021 17:28:16 +0100 Subject: [PATCH] Fix crash on calling play() in a uninitialized AnimatedSprite2D When AnimatedSprite2D::play() was called before SpriteFrames has been initialized, a crach occurred (issue #46013). Modification : An error message on null check test has been added to prevent crash. Fix #46013. --- scene/2d/animated_sprite_2d.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index 359044a5769..dfc08583f2f 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -382,6 +382,7 @@ bool AnimatedSprite2D::_is_playing() const { } void AnimatedSprite2D::play(const StringName &p_animation, const bool p_backwards) { + ERR_FAIL_NULL_MSG(frames, "Can't play AnimatedSprite2D without a valid SpriteFrames resource."); backwards = p_backwards; if (p_animation) {