From 5dcd1c270974c4fbc92e5843c9141e4b5eb5f8e7 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Wed, 25 Nov 2020 19:06:02 +0000 Subject: [PATCH] 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. --- AK/StringImpl.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/AK/StringImpl.cpp b/AK/StringImpl.cpp index eae881764b7..4fac3401ca5 100644 --- a/AK/StringImpl.cpp +++ b/AK/StringImpl.cpp @@ -103,9 +103,6 @@ RefPtr 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];