Title: [138187] trunk/Source/WTF
Revision
138187
Author
oli...@apple.com
Date
2012-12-19 12:17:25 -0800 (Wed, 19 Dec 2012)

Log Message

WTF String from ASCIILiteral fails to correctly handle empty strings.
https://bugs.webkit.org/show_bug.cgi?id=105453

Reviewed by Anders Carlsson.

When we have an zero length literal we should return the empty StringImpl.

* wtf/text/StringImpl.cpp:
(WTF::StringImpl::createFromLiteral):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (138186 => 138187)


--- trunk/Source/WTF/ChangeLog	2012-12-19 20:03:12 UTC (rev 138186)
+++ trunk/Source/WTF/ChangeLog	2012-12-19 20:17:25 UTC (rev 138187)
@@ -1,3 +1,15 @@
+2012-12-19  Oliver Hunt  <oli...@apple.com>
+
+        WTF String from ASCIILiteral fails to correctly handle empty strings.
+        https://bugs.webkit.org/show_bug.cgi?id=105453
+
+        Reviewed by Anders Carlsson.
+
+        When we have an zero length literal we should return the empty StringImpl.
+
+        * wtf/text/StringImpl.cpp:
+        (WTF::StringImpl::createFromLiteral):
+
 2012-12-18  Yury Semikhatsky  <yu...@chromium.org>
 
         Web Inspector: show cached images under MemoryCache -> Images section

Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (138186 => 138187)


--- trunk/Source/WTF/wtf/text/StringImpl.cpp	2012-12-19 20:03:12 UTC (rev 138186)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp	2012-12-19 20:17:25 UTC (rev 138187)
@@ -158,6 +158,8 @@
 PassRefPtr<StringImpl> StringImpl::createFromLiteral(const char* characters)
 {
     size_t length = strlen(characters);
+    if (!length)
+        return empty();
     ASSERT(charactersAreAllASCII<LChar>(reinterpret_cast<const LChar*>(characters), length));
     return adoptRef(new StringImpl(characters, length, ConstructFromLiteral));
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to