commit fdc4af244da2bfa814462c1b3950a95c3959f8eb
parent 81916340a7c090c9f3ddf7a3cafc2cbbaaf5ea71
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 24 Oct 2022 17:47:00 +0200
cc1: Avoid undefined behaviour
A compound literal has a timelife limited to the scope where it
is defined and in this case the object was accessed out of its
timelife.
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/cmd/cc/cc1/expr.c b/src/cmd/cc/cc1/expr.c
@@ -676,14 +676,14 @@ arguments(Node *np)
{
int toomany, n, op;
Node *par = NULL, *arg;
- Type *argtype, **targs, *tp = np->type, *rettype;
+ Type *argtype, *tp = np->type, *rettype;
+ Type **targs = (Type *[]) {ellipsistype};
if (tp->op == PTR && tp->type->op == FTN) {
np = content(OPTR, np);
tp = np->type;
}
if (tp->op != FTN) {
- targs = (Type *[]) {ellipsistype};
n = 1;
rettype = inttype;
errorp("function or function pointer expected");