scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit a02c7e4fc2ca724738b578f9e1540d463079aa5a
parent cf2d0f641671237b6532bf60623e9c17727c2929
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Mon, 30 Mar 2026 15:38:44 +0200

cc1: Accept np NULL in autocomp()

The function autocomp() accepts a np NULL parameter in different places
but in the case of an array parameter it was not accepted which was a
bit weird and produced error paths to produce segmentation faults.

Diffstat:
Msrc/cmd/scc-cc/cc1/init.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/cmd/scc-cc/cc1/init.c b/src/cmd/scc-cc/cc1/init.c @@ -407,7 +407,7 @@ autocomp(Symbol *sym, Node *np, Type *tp, unsigned long long *addr) break; case STRUCT: case ARY: - if ((np->flags & NCONST) != 0) { + if (np && (np->flags & NCONST) != 0) { Symbol *hidden = newsym(NS_IDEN, NULL); hidden->id = newid(); hidden->type = init->type;