Fix error handling case in Cache::dumpContentsToFile()
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Aug 2015 19:20:27 +0000 (19:20 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Aug 2015 19:20:27 +0000 (19:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147567

Reviewed by Andreas Kling.

Cache::dumpContentsToFile() was expecting openFile() to return 0 in case
of error. However, it returns invalidPlatformFileHandle, which is -1 on
Unix.

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::dumpContentsToFile):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187749 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp

index 4606641..8d962e4 100644 (file)
@@ -1,5 +1,19 @@
 2015-08-03  Chris Dumez  <cdumez@apple.com>
 
+        Fix error handling case in Cache::dumpContentsToFile()
+        https://bugs.webkit.org/show_bug.cgi?id=147567
+
+        Reviewed by Andreas Kling.
+
+        Cache::dumpContentsToFile() was expecting openFile() to return 0 in case
+        of error. However, it returns invalidPlatformFileHandle, which is -1 on
+        Unix.
+
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::Cache::dumpContentsToFile):
+
+2015-08-03  Chris Dumez  <cdumez@apple.com>
+
         Make sure WebMemorySampler doesn't leak file descriptor
         https://bugs.webkit.org/show_bug.cgi?id=147564
 
index 5644211..9ec2edf 100644 (file)
@@ -482,7 +482,7 @@ void Cache::dumpContentsToFile()
     if (!m_storage)
         return;
     auto fd = WebCore::openFile(dumpFilePath(), WebCore::OpenForWrite);
-    if (!fd)
+    if (!WebCore::isHandleValid(fd))
         return;
     auto prologue = String("{\n\"entries\": [\n").utf8();
     WebCore::writeToFile(fd, prologue.data(), prologue.length());