Don't crash if ivar_getTypeEncoding returns NULL.
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 3 Jun 2014 22:33:00 +0000 (15:33 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Tue, 3 Jun 2014 22:33:00 +0000 (15:33 -0700)
ObjectiveC/Library.mm

index a685816ecbb22f3d3c30d86494575f019da97150..53d0611ac566f534c77f35988cb95b564ffb72c8 100644 (file)
@@ -2048,6 +2048,7 @@ static void CYBitField(unsigned &length, unsigned &shift, id self, Ivar ivar, co
             break;
         else if (ivar_getOffset(ivars[i]) == offset) {
             const char *encoding(ivar_getTypeEncoding(ivars[i]));
+            _assert(encoding != NULL);
             _assert(encoding[0] == 'b');
             shift += CYCastDouble(encoding + 1);
         }
@@ -2071,6 +2072,7 @@ static JSValueRef Internal_getProperty(JSContextRef context, JSObjectRef object,
         void *data(reinterpret_cast<uint8_t *>(self) + offset);
 
         const char *encoding(ivar_getTypeEncoding(ivar));
+        _assert(encoding != NULL);
         if (encoding[0] == 'b') {
             unsigned length, shift;
             CYBitField(length, shift, self, ivar, encoding, offset);
@@ -2099,6 +2101,7 @@ static bool Internal_setProperty(JSContextRef context, JSObjectRef object, JSStr
         void *data(reinterpret_cast<uint8_t *>(self) + offset);
 
         const char *encoding(ivar_getTypeEncoding(ivar));
+        _assert(encoding != NULL);
         if (encoding[0] == 'b') {
             unsigned length, shift;
             CYBitField(length, shift, self, ivar, encoding, offset);