]> git.saurik.com Git - cycript.git/blobdiff - ObjectiveC/Library.mm
Fix issue in 64-bit choose() reported by heardrwt.
[cycript.git] / ObjectiveC / Library.mm
index c50f5b78f5ecdbb83bb3bd954602f4391c2008ca..a685816ecbb22f3d3c30d86494575f019da97150 100644 (file)
@@ -1470,8 +1470,10 @@ static SEL CYCastSEL(JSContextRef context, JSValueRef value) {
     if (JSValueIsObjectOfClass(context, value, Selector_)) {
         Selector_privateData *internal(reinterpret_cast<Selector_privateData *>(JSObjectGetPrivate((JSObjectRef) value)));
         return reinterpret_cast<SEL>(internal->value_);
-    } else
-        return CYCastPointer<SEL>(context, value);
+    } else {
+        CYPool pool;
+        return sel_registerName(CYPoolCString(pool, context, value));
+    }
 }
 
 void *CYObjectiveC_ExecuteStart(JSContextRef context) { CYSadTry {
@@ -2332,7 +2334,12 @@ static void choose_(task_t task, void *baton, unsigned type, vm_range_t *ranges,
 
         size_t needed(class_getInstanceSize(*result));
         // XXX: if (size < needed)
-        if (needed <= 496 && (needed + 15) / 16 * 16 != size || needed > 496 && (needed + 511) / 512 * 512 != size)
+
+        size_t boundary(496);
+#ifdef __LP64__
+        boundary *= 2;
+#endif
+        if (needed <= boundary && (needed + 15) / 16 * 16 != size || needed > boundary && (needed + 511) / 512 * 512 != size)
             continue;
         CYArrayPush(context, choice->results_, CYCastJSValue(context, reinterpret_cast<id>(data)));
     }