Quellcode durchsuchen

VLCHTTP: Use firstObject to avoid potential crash

Soomin Lee vor 6 Jahren
Ursprung
Commit
dc2cae1e89
2 geänderte Dateien mit 4 neuen und 2 gelöschten Zeilen
  1. 2 1
      Sources/VLCHTTPConnection.m
  2. 2 1
      Sources/VLCHTTPUploaderController.m

+ 2 - 1
Sources/VLCHTTPConnection.m

@@ -622,7 +622,8 @@
 
     // create the path where to store the media temporarily
     NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
-    NSString *uploadDirPath = [searchPaths[0] stringByAppendingPathComponent:kVLCHTTPUploadDirectory];
+    NSString *uploadDirPath = [searchPaths.firstObject
+                               stringByAppendingPathComponent:kVLCHTTPUploadDirectory];
     NSFileManager *fileManager = [NSFileManager defaultManager];
 
     BOOL isDir = YES;

+ 2 - 1
Sources/VLCHTTPUploaderController.m

@@ -359,7 +359,8 @@
         return;
 
     NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
-    NSString* uploadDirPath = [searchPaths[0] stringByAppendingPathComponent:kVLCHTTPUploadDirectory];
+    NSString *uploadDirPath = [searchPaths.firstObject
+                               stringByAppendingPathComponent:kVLCHTTPUploadDirectory];
     NSFileManager *fileManager = [NSFileManager defaultManager];
     if ([fileManager fileExistsAtPath:uploadDirPath])
         [fileManager removeItemAtPath:uploadDirPath error:nil];