cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject ios commit: [CB-2631] Fix crash when bad url given to FT.upload
Date Wed, 06 Mar 2013 18:58:43 GMT
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 <agrieve@chromium.org>
Authored: Wed Mar 6 10:58:06 2013 -0800
Committer: Andrew Grieve <agrieve@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];


Mime
View raw message