File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -692,6 +692,12 @@ private struct UNIXPath: Path {
692692
693693 init ( validatingAbsolutePath path: String ) throws {
694694 #if os(Windows)
695+ // Explicitly handle the empty path, since retrieving
696+ // `fileSystemRepresentation` of it is illegal.
697+ guard !path. isEmpty else {
698+ throw PathValidationError . invalidAbsolutePath ( path)
699+ }
700+
695701 let fsr : UnsafePointer < Int8 > = path. fileSystemRepresentation
696702 defer { fsr. deallocate ( ) }
697703
@@ -714,6 +720,12 @@ private struct UNIXPath: Path {
714720
715721 init ( validatingRelativePath path: String ) throws {
716722 #if os(Windows)
723+ // Explicitly handle the empty path, since retrieving
724+ // `fileSystemRepresentation` of it is illegal.
725+ guard !path. isEmpty else {
726+ throw PathValidationError . invalidRelativePath ( path)
727+ }
728+
717729 let fsr : UnsafePointer < Int8 > = path. fileSystemRepresentation
718730 defer { fsr. deallocate ( ) }
719731
You can’t perform that action at this time.
0 commit comments