Fix for Coverity CID#10: out-of-bounds array access

This commit is contained in:
tg
2007-05-13 19:00:30 +00:00
parent a3e012c69b
commit 655b50a7d1

9
syn.c
View File

@@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.12 2007/03/04 03:04:28 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/syn.c,v 1.13 2007/05/13 19:00:30 tg Exp $");
struct nesting_state { struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */ int start_token; /* token than began nesting (eg, FOR) */
@@ -849,11 +849,10 @@ dbtestp_isa(Test_env *te, Test_meta meta)
ret = uqword && strcmp(yylval.cp, db_close) == 0; ret = uqword && strcmp(yylval.cp, db_close) == 0;
if (ret) { if (ret) {
ACCEPT; ACCEPT;
if (meta != TM_END) { if (meta < NELEM(dbtest_tokens))
if (!save) save = wdcopy(dbtest_tokens[(int)meta], ATEMP);
save = wdcopy(dbtest_tokens[(int) meta], ATEMP); if (save)
XPput(*te->pos.av, save); XPput(*te->pos.av, save);
}
} }
return ret; return ret;
} }