Fix crash with String copy from with NULL string parameter

(cherry picked from commit 4b2a44054a)
This commit is contained in:
geequlim 2017-06-25 21:57:06 +08:00 committed by Rémi Verschelde
parent 3070267c4c
commit 9d49491afd

View file

@ -64,6 +64,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)
@ -87,6 +93,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)