Skip to content

Commit

Permalink
Merge pull request #5948 from pec1985/TIMOB-17448
Browse files Browse the repository at this point in the history
[TIMOB-17448] iOS - Fixed crash when module.exports is not an object
  • Loading branch information
srahim committed Aug 20, 2014
2 parents d28980b + 1fd6f05 commit dde2bbc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions iphone/Classes/KrollCallback.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,15 @@ - (void)replaceValue:(id)value forKey:(NSString*)key notification:(BOOL)notify
*/
KrollContext * context = [bridge krollContext];
TiValueRef valueRef = [KrollObject toValue:context value:value];
TiStringRef keyRef = TiStringCreateWithCFString((CFStringRef) key);
TiObjectSetProperty([context context], jsobject, keyRef, valueRef, kTiPropertyAttributeReadOnly, NULL);
TiStringRelease(keyRef);

/*
* Properties can only be added to objects
*/
if(TiValueIsObject([context context], jsobject)) {
TiStringRef keyRef = TiStringCreateWithCFString((CFStringRef) key);
TiObjectSetProperty([context context], jsobject, keyRef, valueRef, kTiPropertyAttributeReadOnly, NULL);
TiStringRelease(keyRef);
}
}

@end
Expand Down

0 comments on commit dde2bbc

Please sign in to comment.