diff options
author | Michael Forney <mforney@mforney.org> | 2019-02-22 23:45:48 -0800 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-02-22 23:45:48 -0800 |
commit | 413034296ee8919c50a632da80237bcb1e106646 (patch) | |
tree | 6e4fa545c7d2794bc3d84ec285b9bec190ce330d /qbe.c | |
parent | 96fa8b352148f3843abe4f95958d765e40089f9b (diff) |
Fix use of uninitialized character in string array
String data in expressions is just an array and is not NULL-terminated.
Diffstat (limited to 'qbe.c')
-rw-r--r-- | qbe.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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}); } |