Changeset 208958 in webkit
- Timestamp:
- Nov 21, 2016 10:30:33 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r208903 r208958 1 2016-11-21 Mark Lam <mark.lam@apple.com> 2 3 Hasher::addCharacters() should be able to handle zero length strings. 4 https://bugs.webkit.org/show_bug.cgi?id=165024 5 6 Reviewed by Yusuke Suzuki. 7 8 Currently, it will fail to handle zero length strings if it has a pending 9 character. The fix is simply to return early if length is 0. 10 11 * wtf/Hasher.h: 12 (WTF::StringHasher::addCharacters): 13 1 14 2016-11-18 Jeremy Jones <jeremyj@apple.com> 2 15 -
trunk/Source/WTF/wtf/Hasher.h
r208349 r208958 1 1 /* 2 * Copyright (C) 2005 , 2006, 2008, 2010, 2013Apple Inc. All rights reserved.2 * Copyright (C) 2005-2006, 2008, 2010, 2013, 2016 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> 4 4 * … … 132 132 template<typename T, UChar Converter(T)> void addCharacters(const T* data, unsigned length) 133 133 { 134 if (m_hasPendingCharacter && length) { 134 if (!length) 135 return; 136 if (m_hasPendingCharacter) { 135 137 m_hasPendingCharacter = false; 136 138 addCharactersAssumingAligned(m_pendingCharacter, Converter(*data++)); -
trunk/Tools/ChangeLog
r208951 r208958 1 2016-11-21 Mark Lam <mark.lam@apple.com> 2 3 Hasher::addCharacters() should be able to handle zero length strings. 4 https://bugs.webkit.org/show_bug.cgi?id=165024 5 6 Reviewed by Yusuke Suzuki. 7 8 * TestWebKitAPI/Tests/WTF/StringHasher.cpp: 9 (TestWebKitAPI::TEST): 10 1 11 2016-11-21 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WTF/StringHasher.cpp
r208387 r208958 265 265 ASSERT_EQ(testBHash5, hasher.hash()); 266 266 ASSERT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked()); 267 268 // Hashing zero characters after hashing other characters. 269 hasher = StringHasher(); 270 hasher.addCharacters(nullLChars, 0); 271 hasher.addCharacters(nullLChars, 0); 272 ASSERT_EQ(emptyStringHash, hasher.hash()); 273 ASSERT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked()); 274 275 hasher = StringHasher(); 276 hasher.addCharacters(testALChars, 1); 277 hasher.addCharacters(nullLChars, 0); 278 ASSERT_EQ(testAHash1, hasher.hash()); 279 ASSERT_EQ(testAHash1 & 0xFFFFFF, hasher.hashWithTop8BitsMasked()); 280 281 hasher = StringHasher(); 282 hasher.addCharacters(testALChars, 2); 283 hasher.addCharacters(nullLChars, 0); 284 ASSERT_EQ(testAHash2, hasher.hash()); 285 ASSERT_EQ(testAHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked()); 286 287 hasher = StringHasher(); 288 hasher.addCharacters(testAUChars, 3); 289 hasher.addCharacters(nullLChars, 0); 290 ASSERT_EQ(testAHash3, hasher.hash()); 291 ASSERT_EQ(testAHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked()); 292 293 hasher = StringHasher(); 294 hasher.addCharacters(testALChars, 4); 295 hasher.addCharacters(nullLChars, 0); 296 ASSERT_EQ(testAHash4, hasher.hash()); 297 ASSERT_EQ(testAHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked()); 298 299 hasher = StringHasher(); 300 hasher.addCharacters(testALChars, 5); 301 hasher.addCharacters(nullLChars, 0); 302 ASSERT_EQ(testAHash5, hasher.hash()); 303 ASSERT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked()); 267 304 } 268 305
Note: See TracChangeset
for help on using the changeset viewer.