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:
Linus Groh 2020-11-25 19:06:02 +00:00 committed by Andreas Kling
parent 4e68f179d6
commit 5dcd1c2709

View file

@ -103,9 +103,6 @@ RefPtr<StringImpl> StringImpl::create(const char* cstring, size_t length, Should
if (!cstring)
return nullptr;
if (!length || !*cstring)
return the_empty_stringimpl();
if (should_chomp) {
while (length) {
char last_ch = cstring[length - 1];