You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/03/06 19:58:43 UTC

ios commit: [CB-2631] Fix crash when bad url given to FT.upload

Updated Branches:
  refs/heads/master 7219c3c72 -> ef327d17e


[CB-2631] Fix crash when bad url given to FT.upload


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/ef327d17
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/ef327d17
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/ef327d17

Branch: refs/heads/master
Commit: ef327d17ef5736ac9cfbca248fdbe0cf855f9b1f
Parents: 7219c3c
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Mar 6 10:58:06 2013 -0800
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Mar 6 10:58:06 2013 -0800

----------------------------------------------------------------------
 CordovaLib/Classes/CDVFileTransfer.m |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/ef327d17/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
index bfa41f0..ad674ad 100644
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ b/CordovaLib/Classes/CDVFileTransfer.m
@@ -291,6 +291,12 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
     } else {
         // Extract the path part out of a file: URL.
         NSString* filePath = [target hasPrefix:@"/"] ? [target copy] : [[NSURL URLWithString:target] path];
+        if (filePath == nil) {
+            // We couldn't find the asset.  Send the appropriate error.
+            CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
+            [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
+            return;
+        }
 
         // Memory map the file so that it can be read efficiently even if it is large.
         NSData* fileData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&err];