Title: [290978] trunk
Revision
290978
Author
sihui_...@apple.com
Date
2022-03-08 00:06:12 -0800 (Tue, 08 Mar 2022)

Log Message

Add early return for empty path in makeAllDirectories
https://bugs.webkit.org/show_bug.cgi?id=237540
rdar://89901536

Reviewed by Chris Dumez.

Source/WTF:

* wtf/posix/FileSystemPOSIX.cpp:
(WTF::FileSystemImpl::makeAllDirectories):

Tools:

* TestWebKitAPI/Tests/WTF/FileSystem.cpp:
(TestWebKitAPI::TEST_F):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (290977 => 290978)


--- trunk/Source/WTF/ChangeLog	2022-03-08 08:01:30 UTC (rev 290977)
+++ trunk/Source/WTF/ChangeLog	2022-03-08 08:06:12 UTC (rev 290978)
@@ -1,3 +1,14 @@
+2022-03-08  Sihui Liu  <sihui_...@apple.com>
+
+        Add early return for empty path in makeAllDirectories
+        https://bugs.webkit.org/show_bug.cgi?id=237540
+        rdar://89901536
+
+        Reviewed by Chris Dumez.
+
+        * wtf/posix/FileSystemPOSIX.cpp:
+        (WTF::FileSystemImpl::makeAllDirectories):
+
 2022-03-07  Per Arne Vollan  <pvol...@apple.com>
 
         Preconnecting after process swap is a page load time improvement on some devices

Modified: trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp (290977 => 290978)


--- trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp	2022-03-08 08:01:30 UTC (rev 290977)
+++ trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp	2022-03-08 08:06:12 UTC (rev 290978)
@@ -270,7 +270,8 @@
 bool makeAllDirectories(const String& path)
 {
     auto fullPath = fileSystemRepresentation(path);
-    if (fullPath.isNull())
+    int length = fullPath.length();
+    if (!length)
         return false;
 
     if (!access(fullPath.data(), F_OK))
@@ -277,7 +278,6 @@
         return true;
 
     char* p = fullPath.mutableData() + 1;
-    int length = fullPath.length();
     if (p[length - 1] == '/')
         p[length - 1] = '\0';
     for (; *p; ++p) {

Modified: trunk/Tools/ChangeLog (290977 => 290978)


--- trunk/Tools/ChangeLog	2022-03-08 08:01:30 UTC (rev 290977)
+++ trunk/Tools/ChangeLog	2022-03-08 08:06:12 UTC (rev 290978)
@@ -1,3 +1,14 @@
+2022-03-08  Sihui Liu  <sihui_...@apple.com>
+
+        Add early return for empty path in makeAllDirectories
+        https://bugs.webkit.org/show_bug.cgi?id=237540
+        rdar://89901536
+
+        Reviewed by Chris Dumez.
+
+        * TestWebKitAPI/Tests/WTF/FileSystem.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2022-03-07  David Kilzer  <ddkil...@apple.com>
 
         Fix Release builds for sanitizers by defining RELEASE_WITHOUT_OPTIMIZATIONS

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp (290977 => 290978)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp	2022-03-08 08:01:30 UTC (rev 290977)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp	2022-03-08 08:06:12 UTC (rev 290978)
@@ -489,6 +489,7 @@
     invalidFolderPath.append('\0');
     invalidFolderPath.append('a');
     EXPECT_FALSE(FileSystem::makeAllDirectories(invalidFolderPath));
+    EXPECT_FALSE(FileSystem::makeAllDirectories(emptyString()));
 }
 
 TEST_F(FileSystemTest, volumeFreeSpace)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to