From: Jay Freeman (saurik) <saurik@saurik.com>
Date: Tue, 3 Jun 2014 22:32:07 +0000 (-0700)
Subject: Fix issue in 64-bit choose() reported by heardrwt.
X-Git-Tag: v0.9.502~21
X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/13c7f2fb8fc0619c8da1b5c8a697f7894479b070?ds=inline

Fix issue in 64-bit choose() reported by heardrwt.
---

diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm
index b7d23ef..a685816 100644
--- a/ObjectiveC/Library.mm
+++ b/ObjectiveC/Library.mm
@@ -2334,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)));
     }