From 413034296ee8919c50a632da80237bcb1e106646 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Fri, 22 Feb 2019 23:45:48 -0800 Subject: Fix use of uninitialized character in string array String data in expressions is just an array and is not NULL-terminated. --- qbe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qbe.c b/qbe.c index 4ff9c28..3a27b43 100644 --- a/qbe.c +++ b/qbe.c @@ -882,7 +882,7 @@ funcinit(struct function *func, struct declaration *d, struct initializer *init) for (; init; init = init->next) { zero(func, d->value, d->type->align, offset, init->start); if (init->expr->kind == EXPRSTRING) { - for (i = 0; i <= init->expr->string.size && i < init->end - init->start; ++i) { + for (i = 0; i < init->expr->string.size && i < init->end - init->start; ++i) { dst = funcinst(func, IADD, &iptr, (struct value *[]){d->value, mkintconst(&iptr, init->start + i)}); funcinst(func, ISTOREB, NULL, (struct value *[]){mkintconst(&i8, init->expr->string.data[i]), dst}); } -- cgit v1.2.3