aboutsummaryrefslogtreecommitdiff
path: root/src/intobject.c
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-01-21 21:11:14 +1300
committerArslaan Pathan <[email protected]>2026-01-21 21:11:14 +1300
commit1205f476a04327530e2e532e201da5bbb9917d9d (patch)
tree681811c89c3203a9ab8582b7269cd1d2f505f444 /src/intobject.c
parent2ccc6ba64ca26c627d3c8127d09b64e69ccbc977 (diff)
downloadpython-0.9.1-patched-QoL-1205f476a04327530e2e532e201da5bbb9917d9d.tar.xz
python-0.9.1-patched-QoL-1205f476a04327530e2e532e201da5bbb9917d9d.zip
Add QoL improvements and improve the README
Diffstat (limited to 'src/intobject.c')
-rw-r--r--src/intobject.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/intobject.c b/src/intobject.c
index 6c700e8..e4ae02b 100644
--- a/src/intobject.c
+++ b/src/intobject.c
@@ -183,6 +183,8 @@ int_sub(v, w)
return newintobject(x);
}
+/* int_mul patched by Arslaan Pathan on 2026-01-21
+ to fix integer overflow on 64-bit systems */
static object *
int_mul(v, w)
intobject *v;
@@ -197,7 +199,10 @@ int_mul(v, w)
a = v->ob_ival;
b = ((intobject *)w) -> ob_ival;
x = (double)a * (double)b;
- if (x > 0x7fffffff || x < (double) (long) 0x80000000)
+ /* hardcode 32-bit integer limit as an integer
+ instead of using integer-width dependent
+ constants such as 0x7fffffff and 0x80000000 */
+ if (x > 2147483647 || x < (double) (long) -2147483648)
return err_ovf();
return newintobject(a * b);
}