Ver código fonte

VLCHTTP: Use firstObject to avoid potential crash

Soomin Lee 6 anos atrás
pai
commit
dc2cae1e89
2 arquivos alterados com 4 adições e 2 exclusões
  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];