Sfoglia il codice sorgente

VLCHTTP: Use firstObject to avoid potential crash

Soomin Lee 6 anni fa
parent
commit
dc2cae1e89
2 ha cambiato i file con 4 aggiunte e 2 eliminazioni
  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];