commit 932bf67c86c7e9fa04dccd6f4d4fff78db7cc50b
parent f2f5a0c8ef744ac4e282378be0a96d2b2de6de7c
Author: Drew DeVault <sir@cmpwn.com>
Date: Mon, 28 Dec 2020 09:59:51 -0500
qbe: fix incorrect branch for body reallocation
This was causing harec to OOM for functions which generated a lot of
IL instructions, for obvious reasons.
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/qbe.c b/src/qbe.c
@@ -214,11 +214,13 @@ push(struct qbe_statements *stmts, struct qbe_statement *stmt)
if (!stmts->stmts) {
stmts->sz = 256;
stmts->ln = 0;
- stmts->stmts = xcalloc(1, sizeof(struct qbe_statement) * stmts->sz);
+ stmts->stmts = xcalloc(1,
+ sizeof(struct qbe_statement) * stmts->sz);
}
- if (stmts->ln + 1 < stmts->sz) {
+ if (stmts->ln + 1 >= stmts->sz) {
stmts->sz *= 2;
- stmts->stmts = xrealloc(stmts->stmts, stmts->sz);
+ stmts->stmts = xrealloc(stmts->stmts,
+ sizeof(struct qbe_statement) * stmts->sz);
}
stmts->stmts[stmts->ln++] = *stmt;
}