From ff45c0814396e9cec0830d042a985d5d45c49701 Mon Sep 17 00:00:00 2001 From: jsjtxietian Date: Mon, 30 Oct 2023 17:54:55 +0800 Subject: [PATCH] Fix FastNoiseLite.get_image crashes with bad param --- modules/noise/noise.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/noise/noise.cpp b/modules/noise/noise.cpp index 65ef07e2847..9b9fd640f45 100644 --- a/modules/noise/noise.cpp +++ b/modules/noise/noise.cpp @@ -166,6 +166,9 @@ Vector> Noise::_get_image(int p_width, int p_height, int p_depth, boo Ref Noise::get_image(int p_width, int p_height, bool p_invert, bool p_in_3d_space, bool p_normalize) const { Vector> images = _get_image(p_width, p_height, 1, p_invert, p_in_3d_space, p_normalize); + if (images.is_empty()) { + return Ref(); + } return images[0]; }