scc

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

commit ac47b6b038c013c2084ef1d8d3d40841034b257c
parent d046f2956ae71450e1d6cfd734c1245d1a8186b8
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 26 Oct 2022 16:32:31 +0200

cc1: Avoid out of border access in cppelse()

Diffstat:
Msrc/cmd/cc/cc1/cpp.c | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/cmd/cc/cc1/cpp.c b/src/cmd/cc/cc1/cpp.c @@ -834,6 +834,11 @@ cppelse(void) static void elif(void) { + if (cppctx == 0) { + cpperror("#elif without #ifdef/ifndef"); + return; + } + elseclause(); if (ifstatus[cppctx-1]) { --cppctx;