mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:57:43 +00:00
AK: Don't return empty StringImpl from create() when char* starts with \0
When creating a StringImpl for a C string that starts with a null-byte, we would ignore the explicitly given length and return the empty StringImpl - presumably to check for "\0", but this leads to false positives ("\0foo") so let's only care about the length.
This commit is contained in:
parent
4e68f179d6
commit
5dcd1c2709
1 changed files with 0 additions and 3 deletions
|
@ -103,9 +103,6 @@ RefPtr<StringImpl> StringImpl::create(const char* cstring, size_t length, Should
|
||||||
if (!cstring)
|
if (!cstring)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (!length || !*cstring)
|
|
||||||
return the_empty_stringimpl();
|
|
||||||
|
|
||||||
if (should_chomp) {
|
if (should_chomp) {
|
||||||
while (length) {
|
while (length) {
|
||||||
char last_ch = cstring[length - 1];
|
char last_ch = cstring[length - 1];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue