diff options
-rw-r--r-- | editors/awk.c | 2 | ||||
-rwxr-xr-x | testsuite/awk.tests | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/editors/awk.c b/editors/awk.c index d0269b9f4..685e8bed8 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -1514,7 +1514,7 @@ static void chain_group(void) | |||
1514 | next_token(TC_SEQSTART); | 1514 | next_token(TC_SEQSTART); |
1515 | n2 = parse_expr(TC_SEMICOL | TC_SEQTERM); | 1515 | n2 = parse_expr(TC_SEMICOL | TC_SEQTERM); |
1516 | if (t_tclass & TC_SEQTERM) { /* for-in */ | 1516 | if (t_tclass & TC_SEQTERM) { /* for-in */ |
1517 | if ((n2->info & OPCLSMASK) != OC_IN) | 1517 | if (!n2 || (n2->info & OPCLSMASK) != OC_IN) |
1518 | syntax_error(EMSG_UNEXP_TOKEN); | 1518 | syntax_error(EMSG_UNEXP_TOKEN); |
1519 | n = chain_node(OC_WALKINIT | VV); | 1519 | n = chain_node(OC_WALKINIT | VV); |
1520 | n->l.n = n2->l.n; | 1520 | n->l.n = n2->l.n; |
diff --git a/testsuite/awk.tests b/testsuite/awk.tests index adab4ae1e..82937bc10 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests | |||
@@ -316,6 +316,9 @@ testing "awk continue" \ | |||
316 | "" \ | 316 | "" \ |
317 | 'BEGIN { if (1) continue; else a = 1 }' | 317 | 'BEGIN { if (1) continue; else a = 1 }' |
318 | 318 | ||
319 | testing "awk handles invalid for loop" \ | ||
320 | "awk '{ for() }' 2>&1" "awk: cmd. line:1: Unexpected token\n" "" "" | ||
321 | |||
319 | # testing "description" "command" "result" "infile" "stdin" | 322 | # testing "description" "command" "result" "infile" "stdin" |
320 | 323 | ||
321 | exit $FAILCOUNT | 324 | exit $FAILCOUNT |