summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-06-25 16:17:42 +0200
committerGitHub <noreply@github.com>2017-06-25 16:17:42 +0200
commit826784d965a5200670f13709d69e3135bf1f4d9e (patch)
tree24ee07711f2c1bae50550aba643f2f0efb97c9d1
parente5d890c23ab6a9cb8edbbdb4a41db7f1a1653941 (diff)
parent4b2a44054a70020bbbad14a710cc92042834a9c1 (diff)
Merge pull request #9357 from GodotExplorer/pr-fix-string-copy_from
Fix crash with String::copy_from with NULL string parameter
-rw-r--r--core/ustring.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 7ccf7fd209..ab4528e495 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -96,6 +96,12 @@ const char *CharString::get_data() const {
void String::copy_from(const char *p_cstr) {
+ if (!p_cstr) {
+
+ resize(0);
+ return;
+ }
+
int len = 0;
const char *ptr = p_cstr;
while (*(ptr++) != 0)
@@ -119,6 +125,12 @@ void String::copy_from(const char *p_cstr) {
void String::copy_from(const CharType *p_cstr, int p_clip_to) {
+ if (!p_cstr) {
+
+ resize(0);
+ return;
+ }
+
int len = 0;
const CharType *ptr = p_cstr;
while (*(ptr++) != 0)