Title: [192085] trunk/Tools
Revision
192085
Author
[email protected]
Date
2015-11-05 15:20:37 -0800 (Thu, 05 Nov 2015)

Log Message

TestWebKitAPI crashed in TestWebKitAPI: TestWebKitAPI::SharedBufferTest_copyBufferCreatedWithContentsOfExistingFile_Test::TestBody
<http://webkit.org/b/150931>
<rdar://problem/23409384>

Reviewed by Youenn Fablet.

* TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp:
(TestWebKitAPI::TEST_F(SharedBufferTest, copyBufferCreatedWithContentsOfExistingFile)):
- Switch from strnstr() to memcmp() since strings are
  not guaranteed to be NULL-terminated.
- Add another expectation that the size is greater than
  zero since memcmp() returns 0 (matching) if the length
  argument is zero.
(TestWebKitAPI::TEST_F(SharedBufferTest, appendBufferCreatedWithContentsOfExistingFile)):
- Same change to keep tests consistent, although the
  second string is NULL-terminated in this case.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (192084 => 192085)


--- trunk/Tools/ChangeLog	2015-11-05 23:17:43 UTC (rev 192084)
+++ trunk/Tools/ChangeLog	2015-11-05 23:20:37 UTC (rev 192085)
@@ -1,3 +1,22 @@
+2015-11-05  David Kilzer  <[email protected]>
+
+        TestWebKitAPI crashed in TestWebKitAPI: TestWebKitAPI::SharedBufferTest_copyBufferCreatedWithContentsOfExistingFile_Test::TestBody
+        <http://webkit.org/b/150931>
+        <rdar://problem/23409384>
+
+        Reviewed by Youenn Fablet.
+
+        * TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp:
+        (TestWebKitAPI::TEST_F(SharedBufferTest, copyBufferCreatedWithContentsOfExistingFile)):
+        - Switch from strnstr() to memcmp() since strings are
+          not guaranteed to be NULL-terminated.
+        - Add another expectation that the size is greater than
+          zero since memcmp() returns 0 (matching) if the length
+          argument is zero.
+        (TestWebKitAPI::TEST_F(SharedBufferTest, appendBufferCreatedWithContentsOfExistingFile)):
+        - Same change to keep tests consistent, although the
+          second string is NULL-terminated in this case.
+
 2015-11-05  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r192073.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp (192084 => 192085)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp	2015-11-05 23:17:43 UTC (rev 192084)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp	2015-11-05 23:20:37 UTC (rev 192085)
@@ -92,8 +92,9 @@
     RefPtr<SharedBuffer> buffer = SharedBuffer::createWithContentsOfFile(tempFilePath());
     ASSERT_NOT_NULL(buffer);
     RefPtr<SharedBuffer> copy = buffer->copy();
+    EXPECT_GT(buffer->size(), 0U);
     EXPECT_TRUE(buffer->size() == copy->size());
-    EXPECT_TRUE(strnstr(buffer->data(), copy->data(), buffer->size()));
+    EXPECT_TRUE(!memcmp(buffer->data(), copy->data(), buffer->size()));
 }
 
 TEST_F(SharedBufferTest, clearBufferCreatedWithContentsOfExistingFile)
@@ -105,14 +106,13 @@
     EXPECT_TRUE(!buffer->data());
 }
 
-
 TEST_F(SharedBufferTest, appendBufferCreatedWithContentsOfExistingFile)
 {
     RefPtr<SharedBuffer> buffer = SharedBuffer::createWithContentsOfFile(tempFilePath());
     ASSERT_NOT_NULL(buffer);
     buffer->append("a", 1);
     EXPECT_TRUE(buffer->size() == (strlen(SharedBufferTestData) + 1));
-    EXPECT_TRUE(strnstr(buffer->data(), SharedBufferTestData, strlen(SharedBufferTestData)));
+    EXPECT_TRUE(!memcmp(buffer->data(), SharedBufferTestData, strlen(SharedBufferTestData)));
     EXPECT_EQ('a', buffer->data()[strlen(SharedBufferTestData)]);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to