scc

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

commit 4f5352fb2ecb3babe3122478bf0576f8905f1afc
parent 6ab70653836a3885179e12bb5ab14032bd1fb224
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 14 Feb 2017 22:39:11 +0100

[cc1] Fix segfault in mktype()

The patch 6ab66ac added a check about the last parameter
in the parameter list, but this check was incorrect when nelem == 0,
because we were accesing further or the borders of the array.

Diffstat:
Mcc1/types.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cc1/types.c b/cc1/types.c @@ -301,7 +301,7 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[]) type.letter = L_FUNCTION; break; case FTN: - if (pars[nelem-1] == ellipsistype) + if (nelem > 0 && pars[nelem-1] == ellipsistype) type.prop |= TELLIPSIS; type.letter = L_FUNCTION; break;