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/01/11 21:31:59 UTC

ios commit: Fix trying to mutate an immutable NSArray in CDVInvokedUrlCommand.

Updated Branches:
  refs/heads/master 20b20b8d4 -> 7e388ad7a


Fix trying to mutate an immutable NSArray in CDVInvokedUrlCommand.

Happens only when dealing with the newly-introduced NSData.


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

Branch: refs/heads/master
Commit: 7e388ad7ae253e5a8b0b2ba2ca810a42ff782587
Parents: 20b20b8
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri Jan 11 15:30:54 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Jan 11 15:30:54 2013 -0500

----------------------------------------------------------------------
 CordovaLib/Classes/CDVInvokedUrlCommand.m |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7e388ad7/CordovaLib/Classes/CDVInvokedUrlCommand.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInvokedUrlCommand.m b/CordovaLib/Classes/CDVInvokedUrlCommand.m
index 17f3091..6c7a856 100644
--- a/CordovaLib/Classes/CDVInvokedUrlCommand.m
+++ b/CordovaLib/Classes/CDVInvokedUrlCommand.m
@@ -65,6 +65,8 @@
 
 - (void)massageArguments
 {
+    NSMutableArray* newArgs = nil;
+
     for (NSUInteger i = 0, count = [_arguments count]; i < count; ++i) {
         id arg = [_arguments objectAtIndex:i];
         if (![arg isKindOfClass:[NSDictionary class]]) {
@@ -79,7 +81,11 @@
         if (!data) {
             continue;
         }
-        [(NSMutableArray*) _arguments replaceObjectAtIndex:i withObject:[NSData dataFromBase64String:data]];
+        if (newArgs == nil) {
+            newArgs = [NSMutableArray arrayWithArray:_arguments];
+            _arguments = newArgs;
+        }
+        [newArgs replaceObjectAtIndex:i withObject:[NSData dataFromBase64String:data]];
     }
 }