]> git.saurik.com Git - cycript.git/blobdiff - Decode.cpp
In trampoline, make $strlcpy not crash given NULL.
[cycript.git] / Decode.cpp
index dd2bc02de55aa8ee53e09af12478b4fa6aed13e5..bdef46b80e71727190797e95fddb55cb6c808322 100644 (file)
@@ -42,11 +42,14 @@ CYTypedIdentifier *Decode_(CYPool &pool, struct sig::Type *type) {
         case sig::selector_P: return $ CYTypedIdentifier($ CYTypeVariable("SEL"));
 
         case sig::block_P: {
         case sig::selector_P: return $ CYTypedIdentifier($ CYTypeVariable("SEL"));
 
         case sig::block_P: {
-            _assert(type->data.signature.count != 0);
-            CYTypedParameter *parameter(NULL);
-            for (size_t i(type->data.signature.count - 1); i != 0; --i)
-                parameter = $ CYTypedParameter(Decode(pool, type->data.signature.elements[i].type), parameter);
-            return Decode(pool, type->data.signature.elements[0].type)->Modify($ CYTypeBlockWith(parameter));
+            if (type->data.signature.count == 0)
+                return $ CYTypedIdentifier($ CYTypeVariable("NSBlock"), $ CYTypePointerTo());
+            else {
+                CYTypedParameter *parameter(NULL);
+                for (size_t i(type->data.signature.count - 1); i != 0; --i)
+                    parameter = $ CYTypedParameter(Decode(pool, type->data.signature.elements[i].type), parameter);
+                return Decode(pool, type->data.signature.elements[0].type)->Modify($ CYTypeBlockWith(parameter));
+            }
         } break;
 
         case sig::object_P: {
         } break;
 
         case sig::object_P: {