From: Jay Freeman (saurik) Date: Sat, 9 Jan 2016 15:04:45 +0000 (-0800) Subject: JSObjectMakeArray fallback didn't handle length 1. X-Git-Tag: v0.9.590~22 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/d6e14b17d2f8c257a9758eee0cf066ba48949c88?ds=sidebyside JSObjectMakeArray fallback didn't handle length 1. --- diff --git a/Execute.cpp b/Execute.cpp index 48dc478..3399c86 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -181,11 +181,12 @@ static JSObjectRef (*JSObjectMakeArray$)(JSContextRef, size_t, const JSValueRef[ JSObjectRef CYObjectMakeArray(JSContextRef context, size_t length, const JSValueRef values[]) { if (JSObjectMakeArray$ != NULL) return _jsccall(*JSObjectMakeArray$, context, length, values); - else { - JSObjectRef Array(CYGetCachedObject(context, CYJSString("Array"))); - JSValueRef value(CYCallAsFunction(context, Array, NULL, length, values)); - return CYCastJSObject(context, value); - } + JSObjectRef Array(CYGetCachedObject(context, CYJSString("Array"))); + bool wat(length == 1 && JSValueGetType(context, values[0]) == kJSTypeNumber); + JSValueRef value(CYCallAsFunction(context, Array, NULL, wat ? 0 : length, values)); + JSObjectRef object(CYCastJSObject(context, value)); + if (wat) CYArrayPush(context, object, 1, values); + return object; } static JSClassRef All_;