File tree Expand file tree Collapse file tree 2 files changed +17
-13
lines changed
Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -588,7 +588,9 @@ extension Path {
588588extension Path {
589589 public static func glob( _ pattern: String ) -> [ Path ] {
590590 var gt = glob_t ( )
591- let cPattern = strdup ( pattern)
591+ guard let cPattern = strdup ( pattern) else {
592+ fatalError ( " strdup returned null: Likely out of memory " )
593+ }
592594 defer {
593595 globfree ( & gt)
594596 free ( cPattern)
@@ -619,8 +621,10 @@ extension Path {
619621 }
620622
621623 public func match( _ pattern: String ) -> Bool {
622- let cPattern = strdup ( pattern)
623- let cPath = strdup ( path)
624+ guard let cPattern = strdup ( pattern) ,
625+ let cPath = strdup ( path) else {
626+ fatalError ( " strdup returned null: Likely out of memory " )
627+ }
624628 defer {
625629 free ( cPattern)
626630 free ( cPath)
Original file line number Diff line number Diff line change @@ -290,12 +290,12 @@ describe("PathKit") {
290290 let current = Path . current
291291 let error = ThrowError ( )
292292
293- try expect {
293+ try expect ( {
294294 try Path ( " /usr/bin " ) . chdir {
295295 try expect ( Path . current) == Path ( " /usr/bin " )
296296 throw error
297297 }
298- } . toThrow ( error)
298+ } ) . toThrow ( error)
299299
300300 try expect ( Path . current) == current
301301 }
@@ -324,9 +324,9 @@ describe("PathKit") {
324324 $0. it ( " errors when you read from a non-existing file as NSData " ) {
325325 let path = Path ( " /tmp/pathkit-testing " )
326326
327- try expect {
327+ try expect ( {
328328 try path. read ( ) as Data
329- } . toThrow ( )
329+ } ) . toThrow ( )
330330 }
331331
332332 $0. it ( " can read a String from a file " ) {
@@ -339,9 +339,9 @@ describe("PathKit") {
339339 $0. it ( " errors when you read from a non-existing file as a String " ) {
340340 let path = Path ( " /tmp/pathkit-testing " )
341341
342- try expect {
342+ try expect ( {
343343 try path. read ( ) as String
344- } . toThrow ( )
344+ } ) . toThrow ( )
345345 }
346346 }
347347
@@ -364,9 +364,9 @@ describe("PathKit") {
364364 let path = Path ( " / " )
365365 let data = " Hi " . data ( using: String . Encoding. utf8, allowLossyConversion: true )
366366
367- try expect {
367+ try expect ( {
368368 try path. write ( data!)
369- } . toThrow ( )
369+ } ) . toThrow ( )
370370 #endif
371371 }
372372
@@ -384,9 +384,9 @@ describe("PathKit") {
384384 #else
385385 let path = Path ( " / " )
386386
387- try expect {
387+ try expect ( {
388388 try path. write ( " hi " )
389- } . toThrow ( )
389+ } ) . toThrow ( )
390390 #endif
391391 }
392392 }
You can’t perform that action at this time.
0 commit comments