commit 4f5352fb2ecb3babe3122478bf0576f8905f1afc
Author: Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Tue Feb 14 22:39:11 2017 +0100
Commit: Roberto E. Vargas Caballero <[email protected]>
CommitDate: Tue Feb 14 22:39:11 2017 +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.
diff --git a/cc1/types.c b/cc1/types.c
index 7d446ef..a367d0b 100644
--- 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;