summary refs log tree commit diff
path: root/amd64
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-04-25 11:30:06 -0700
committerQuentin Carbonneaux <quentin@c9x.me>2019-04-26 14:12:16 +0200
commit659245773a7cad1954d975ea2e262c8a0c804689 (patch)
treeddbd4a342996f7ccad72771798a0c9c101ed2e8b /amd64
parent905575d9e6779d795e3f014e99c76c3189b38283 (diff)
downloadroux-659245773a7cad1954d975ea2e262c8a0c804689.tar.gz
amd64/isel: Error if alloc size doesn't fit in Tmp slot type
Diffstat (limited to 'amd64')
-rw-r--r--amd64/isel.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/amd64/isel.c b/amd64/isel.c
index e5202cb..22e1e14 100644
--- a/amd64/isel.c
+++ b/amd64/isel.c
@@ -588,6 +588,8 @@ amd64_isel(Fn *fn)
 					err("invalid alloc size %"PRId64, sz);
 				sz = (sz + n-1) & -n;
 				sz /= 4;
+				if (sz > INT_MAX - fn->slot)
+					die("alloc too large");
 				fn->tmp[i->to.val].slot = fn->slot;
 				fn->slot += sz;
 				*i = (Ins){.op = Onop};