aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-19 22:35:22 +0200
committerlemon <lsof@mailbox.org>2023-06-19 22:35:22 +0200
commit6fa5dbadce1f54d96e44c195167016278621ace1 (patch)
treeb321fbd1eb79bb719811f86b2d20c5b56bf188dd
parent61367525aea8f3f11c29e628fe49768dda959cef (diff)
regalloc: alloc extra memory for alloc map
regalloc itself can insert instructions so this was causing out of bounds read errors
-rw-r--r--regalloc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/regalloc.c b/regalloc.c
index c3afe70..ed5af2c 100644
--- a/regalloc.c
+++ b/regalloc.c
@@ -257,7 +257,7 @@ regalloc(struct function *fn)
struct rega ra = {0};
vinit(&stkslotrefs, stkslotrefsbuf, arraylength(stkslotrefsbuf));
- ra.allocs = xcalloc(ninstr * sizeof(struct alloc));
+ ra.allocs = xcalloc((ninstr*2 < MAXINSTR ? ninstr*2 : MAXINSTR) * sizeof(struct alloc));
ra.nfreegpr = mctarg->ngpr - popcnt(mctarg->rglob->u);
ra.nfreefpr = mctarg->nfpr;
for (int i = 0; i < MAXREGS; ++i)