Merge pull request #9357 from GodotExplorer/pr-fix-string-copy_from
Fix crash with String::copy_from with NULL string parameter
This commit is contained in:
commit
826784d965
@ -96,6 +96,12 @@ const char *CharString::get_data() const {
|
|||||||
|
|
||||||
void String::copy_from(const char *p_cstr) {
|
void String::copy_from(const char *p_cstr) {
|
||||||
|
|
||||||
|
if (!p_cstr) {
|
||||||
|
|
||||||
|
resize(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
const char *ptr = p_cstr;
|
const char *ptr = p_cstr;
|
||||||
while (*(ptr++) != 0)
|
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) {
|
void String::copy_from(const CharType *p_cstr, int p_clip_to) {
|
||||||
|
|
||||||
|
if (!p_cstr) {
|
||||||
|
|
||||||
|
resize(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
const CharType *ptr = p_cstr;
|
const CharType *ptr = p_cstr;
|
||||||
while (*(ptr++) != 0)
|
while (*(ptr++) != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user