Fix issue 2307

In case sso use memmove to avoid memory overlapping issues
This commit is contained in:
Dmitriy Tretyakov 2024-09-23 09:41:42 +03:00 committed by Milo Yip
parent 7c73dd7de7
commit 805d7ed5df

View File

@ -2445,13 +2445,14 @@ private:
data_.f.flags = kShortStringFlag;
data_.ss.SetLength(s.length);
str = data_.ss.str;
std::memmove(str, s, s.length * sizeof(Ch));
} else {
data_.f.flags = kCopyStringFlag;
data_.s.length = s.length;
str = static_cast<Ch *>(allocator.Malloc((s.length + 1) * sizeof(Ch)));
SetStringPointer(str);
}
std::memcpy(str, s, s.length * sizeof(Ch));
}
str[s.length] = '\0';
}