From 3b4d7a723d8ede21e0b83f02e3ef7191a4720a46 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 6 Feb 2022 10:10:30 +0100 Subject: [PATCH] Return an empty string in substr if len is 0. --- core/string.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/string.cpp b/core/string.cpp index b761d3c..fbf8af4 100644 --- a/core/string.cpp +++ b/core/string.cpp @@ -174,6 +174,10 @@ void String::get_substr_nt(char *into_buf, const int start_index, const int len) } String String::substr(const int start_index, const int len) const { + if (len == 0) { + return String(); + } + ERR_FAIL_INDEX_V(start_index, _size, String()); int sil = start_index + len;