summaryrefslogtreecommitdiffstats
path: root/core/ustring.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-02-11 10:22:36 +0100
committerGitHub <noreply@github.com>2020-02-11 10:22:36 +0100
commit0b4b24883d8fe7ee3f4c7a861df0bad1d12a319c (patch)
tree5c76de23b233cc2e37db1ba50321aa8f4aa07208 /core/ustring.cpp
parent6fb64054088d0b4da2b35d3d730820550605f7a7 (diff)
parent70b0fad25a0e35ddcbf4b83d3efcdf861ee2c8f3 (diff)
downloadredot-engine-0b4b24883d8fe7ee3f4c7a861df0bad1d12a319c.tar.gz
Merge pull request #33731 from madmiraal/fix-c4996-warning
Fix Visual Studio throwing C4996 warning in ustring.cpp.
Diffstat (limited to 'core/ustring.cpp')
-rw-r--r--core/ustring.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 08418463a0..8030efcc2b 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -146,9 +146,11 @@ void CharString::copy_from(const char *p_cstr) {
return;
}
- resize(len + 1); // include terminating null char
+ Error err = resize(++len); // include terminating null char
- strcpy(ptrw(), p_cstr);
+ ERR_FAIL_COND_MSG(err != OK, "Failed to copy C-string.");
+
+ memcpy(ptrw(), p_cstr, len);
}
void String::copy_from(const char *p_cstr) {