Modified: trunk/Source/WTF/ChangeLog (208957 => 208958)
--- trunk/Source/WTF/ChangeLog 2016-11-22 03:35:25 UTC (rev 208957)
+++ trunk/Source/WTF/ChangeLog 2016-11-22 06:30:33 UTC (rev 208958)
@@ -1,3 +1,16 @@
+2016-11-21 Mark Lam <[email protected]>
+
+ Hasher::addCharacters() should be able to handle zero length strings.
+ https://bugs.webkit.org/show_bug.cgi?id=165024
+
+ Reviewed by Yusuke Suzuki.
+
+ Currently, it will fail to handle zero length strings if it has a pending
+ character. The fix is simply to return early if length is 0.
+
+ * wtf/Hasher.h:
+ (WTF::StringHasher::addCharacters):
+
2016-11-18 Jeremy Jones <[email protected]>
Add runtime flag to enable pointer lock. Enable pointer lock feature for mac.
Modified: trunk/Source/WTF/wtf/Hasher.h (208957 => 208958)
--- trunk/Source/WTF/wtf/Hasher.h 2016-11-22 03:35:25 UTC (rev 208957)
+++ trunk/Source/WTF/wtf/Hasher.h 2016-11-22 06:30:33 UTC (rev 208958)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005, 2006, 2008, 2010, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2005-2006, 2008, 2010, 2013, 2016 Apple Inc. All rights reserved.
* Copyright (C) 2010 Patrick Gansterer <[email protected]>
*
* This library is free software; you can redistribute it and/or
@@ -131,7 +131,9 @@
template<typename T, UChar Converter(T)> void addCharacters(const T* data, unsigned length)
{
- if (m_hasPendingCharacter && length) {
+ if (!length)
+ return;
+ if (m_hasPendingCharacter) {
m_hasPendingCharacter = false;
addCharactersAssumingAligned(m_pendingCharacter, Converter(*data++));
--length;
Modified: trunk/Tools/ChangeLog (208957 => 208958)
--- trunk/Tools/ChangeLog 2016-11-22 03:35:25 UTC (rev 208957)
+++ trunk/Tools/ChangeLog 2016-11-22 06:30:33 UTC (rev 208958)
@@ -1,3 +1,13 @@
+2016-11-21 Mark Lam <[email protected]>
+
+ Hasher::addCharacters() should be able to handle zero length strings.
+ https://bugs.webkit.org/show_bug.cgi?id=165024
+
+ Reviewed by Yusuke Suzuki.
+
+ * TestWebKitAPI/Tests/WTF/StringHasher.cpp:
+ (TestWebKitAPI::TEST):
+
2016-11-21 Carlos Alberto Lopez Perez <[email protected]>
[CMake] build fails after update to cmake 3.7
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/StringHasher.cpp (208957 => 208958)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/StringHasher.cpp 2016-11-22 03:35:25 UTC (rev 208957)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/StringHasher.cpp 2016-11-22 06:30:33 UTC (rev 208958)
@@ -264,6 +264,43 @@
hasher.addCharacters(testBUChars + 3);
ASSERT_EQ(testBHash5, hasher.hash());
ASSERT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
+
+ // Hashing zero characters after hashing other characters.
+ hasher = StringHasher();
+ hasher.addCharacters(nullLChars, 0);
+ hasher.addCharacters(nullLChars, 0);
+ ASSERT_EQ(emptyStringHash, hasher.hash());
+ ASSERT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
+
+ hasher = StringHasher();
+ hasher.addCharacters(testALChars, 1);
+ hasher.addCharacters(nullLChars, 0);
+ ASSERT_EQ(testAHash1, hasher.hash());
+ ASSERT_EQ(testAHash1 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
+
+ hasher = StringHasher();
+ hasher.addCharacters(testALChars, 2);
+ hasher.addCharacters(nullLChars, 0);
+ ASSERT_EQ(testAHash2, hasher.hash());
+ ASSERT_EQ(testAHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
+
+ hasher = StringHasher();
+ hasher.addCharacters(testAUChars, 3);
+ hasher.addCharacters(nullLChars, 0);
+ ASSERT_EQ(testAHash3, hasher.hash());
+ ASSERT_EQ(testAHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
+
+ hasher = StringHasher();
+ hasher.addCharacters(testALChars, 4);
+ hasher.addCharacters(nullLChars, 0);
+ ASSERT_EQ(testAHash4, hasher.hash());
+ ASSERT_EQ(testAHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
+
+ hasher = StringHasher();
+ hasher.addCharacters(testALChars, 5);
+ hasher.addCharacters(nullLChars, 0);
+ ASSERT_EQ(testAHash5, hasher.hash());
+ ASSERT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
}
TEST(WTF, StringHasher_addCharactersAssumingAligned)