Skip to content

Commit

Permalink
changed to object_getClass object_setClass to fix crashes in iOS9
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Stokowski committed Sep 18, 2015
1 parent 8215763 commit c9fa7ec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions JSONKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ + (id)allocWithZone:(NSZone *)zone
NSCParameterAssert((objects != NULL) && (_JKArrayClass != NULL) && (_JKArrayInstanceSize > 0UL));
JKArray *array = NULL;
if(JK_EXPECT_T((array = (JKArray *)calloc(1UL, _JKArrayInstanceSize)) != NULL)) { // Directly allocate the JKArray instance via calloc.
array->isa = _JKArrayClass;
object_setClass(array, _JKArrayClass);
if((array = [array init]) == NULL) { return(NULL); }
array->capacity = count;
array->count = count;
Expand Down Expand Up @@ -928,7 +928,7 @@ static void _JKDictionaryResizeIfNeccessary(JKDictionary *dictionary) {
NSCParameterAssert((keys != NULL) && (keyHashes != NULL) && (objects != NULL) && (_JKDictionaryClass != NULL) && (_JKDictionaryInstanceSize > 0UL));
JKDictionary *dictionary = NULL;
if(JK_EXPECT_T((dictionary = (JKDictionary *)calloc(1UL, _JKDictionaryInstanceSize)) != NULL)) { // Directly allocate the JKDictionary instance via calloc.
dictionary->isa = _JKDictionaryClass;
object_setClass(dictionary, _JKDictionaryClass);
if((dictionary = [dictionary init]) == NULL) { return(NULL); }
dictionary->capacity = _JKDictionaryCapacityForCount(count);
dictionary->count = 0UL;
Expand Down Expand Up @@ -2596,7 +2596,7 @@ static int jk_encode_add_atom_to_buffer(JKEncodeState *encodeState, void *object


BOOL workAroundMacOSXABIBreakingBug = (JK_EXPECT_F(((NSUInteger)object) & 0x1)) ? YES : NO;
void *objectISA = (JK_EXPECT_F(workAroundMacOSXABIBreakingBug)) ? NULL : *((void **)objectPtr);
void *objectISA = (JK_EXPECT_F(workAroundMacOSXABIBreakingBug)) ? NULL : object_getClass(objectPtr);
if(JK_EXPECT_F(workAroundMacOSXABIBreakingBug)) { goto slowClassLookup; }

if(JK_EXPECT_T(objectISA == encodeState->fastClassLookup.stringClass)) { isClass = JKClassString; }
Expand Down Expand Up @@ -2804,7 +2804,7 @@ static int jk_encode_add_atom_to_buffer(JKEncodeState *encodeState, void *object
for(idx = 0L; idx < dictionaryCount; idx++) {
if(JK_EXPECT_T(printComma)) { if(JK_EXPECT_F(jk_encode_write1(encodeState, 0L, ","))) { return(1); } }
printComma = 1;
void *keyObjectISA = *((void **)keys[idx]);
void *keyObjectISA = object_getClass(keys[idx]);
if(JK_EXPECT_F(keyObjectISA != encodeState->fastClassLookup.stringClass) && JK_EXPECT_F([(id)keys[idx] isKindOfClass:[NSString class]] == NO)) { jk_encode_error(encodeState, @"Key must be a string object."); return(1); }
if(JK_EXPECT_F(jk_encode_add_atom_to_buffer(encodeState, keys[idx]))) { return(1); }
if(JK_EXPECT_F(jk_encode_write1(encodeState, 0L, ":"))) { return(1); }
Expand Down

0 comments on commit c9fa7ec

Please sign in to comment.