Title: [141030] trunk/Source
Revision
141030
Author
[email protected]
Date
2013-01-28 17:29:12 -0800 (Mon, 28 Jan 2013)

Log Message

String constructed from Literals should be non-empty
https://bugs.webkit.org/show_bug.cgi?id=108103

Reviewed by Eric Carlson.

Source/WebCore: 

Strings from literal should not be constructed from empty strings. Use emptyString()
instead.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::canPlayType):

Source/WTF: 

For efficiency, the construction from literal only works with valid non-empty strings.
One of the constructor was changed to fix an error from HTMLMediaElement.

This patch replaces the branch with an assertions.

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

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (141029 => 141030)


--- trunk/Source/WTF/ChangeLog	2013-01-29 01:22:12 UTC (rev 141029)
+++ trunk/Source/WTF/ChangeLog	2013-01-29 01:29:12 UTC (rev 141030)
@@ -1,3 +1,18 @@
+2013-01-28  Benjamin Poulain  <[email protected]>
+
+        String constructed from Literals should be non-empty
+        https://bugs.webkit.org/show_bug.cgi?id=108103
+
+        Reviewed by Eric Carlson.
+
+        For efficiency, the construction from literal only works with valid non-empty strings.
+        One of the constructor was changed to fix an error from HTMLMediaElement.
+
+        This patch replaces the branch with an assertions.
+
+        * wtf/text/StringImpl.cpp:
+        (WTF::StringImpl::createFromLiteral):
+
 2013-01-28  David Kilzer  <[email protected]>
 
         BUILD FIX: Platform.h:1212:22: error: '__MAC_OS_X_VERSION_MIN_REQUIRED' is not defined, evaluates to 0 [-Werror,-Wundef]

Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (141029 => 141030)


--- trunk/Source/WTF/wtf/text/StringImpl.cpp	2013-01-29 01:22:12 UTC (rev 141029)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp	2013-01-29 01:29:12 UTC (rev 141030)
@@ -151,6 +151,7 @@
 
 PassRefPtr<StringImpl> StringImpl::createFromLiteral(const char* characters, unsigned length)
 {
+    ASSERT_WITH_MESSAGE(length, "Use StringImpl::empty() to create an empty string");
     ASSERT(charactersAreAllASCII<LChar>(reinterpret_cast<const LChar*>(characters), length));
     return adoptRef(new StringImpl(characters, length, ConstructFromLiteral));
 }
@@ -158,8 +159,7 @@
 PassRefPtr<StringImpl> StringImpl::createFromLiteral(const char* characters)
 {
     size_t length = strlen(characters);
-    if (!length)
-        return empty();
+    ASSERT_WITH_MESSAGE(length, "Use StringImpl::empty() to create an empty string");
     ASSERT(charactersAreAllASCII<LChar>(reinterpret_cast<const LChar*>(characters), length));
     return adoptRef(new StringImpl(characters, length, ConstructFromLiteral));
 }

Modified: trunk/Source/WebCore/ChangeLog (141029 => 141030)


--- trunk/Source/WebCore/ChangeLog	2013-01-29 01:22:12 UTC (rev 141029)
+++ trunk/Source/WebCore/ChangeLog	2013-01-29 01:29:12 UTC (rev 141030)
@@ -1,3 +1,16 @@
+2013-01-28  Benjamin Poulain  <[email protected]>
+
+        String constructed from Literals should be non-empty
+        https://bugs.webkit.org/show_bug.cgi?id=108103
+
+        Reviewed by Eric Carlson.
+
+        Strings from literal should not be constructed from empty strings. Use emptyString()
+        instead.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::canPlayType):
+
 2013-01-27  Kentaro Hara  <[email protected]>
 
         Implement CompositionEvent constructor

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (141029 => 141030)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-01-29 01:22:12 UTC (rev 141029)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-01-29 01:29:12 UTC (rev 141030)
@@ -688,7 +688,7 @@
     switch (support)
     {
         case MediaPlayer::IsNotSupported:
-            canPlay = ASCIILiteral("");
+            canPlay = emptyString();
             break;
         case MediaPlayer::MayBeSupported:
             canPlay = ASCIILiteral("maybe");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to