Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: fix assertion after malformed for ...
details: https://anonhg.NetBSD.org/src/rev/296a054ae860
branches: trunk
changeset: 379794:296a054ae860
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jun 19 19:59:01 2021 +0000
description:
lint: fix assertion after malformed for loop
Found using afl.
diffstat:
distrib/sets/lists/tests/mi | 4 +++-
tests/usr.bin/xlint/lint1/Makefile | 4 +++-
tests/usr.bin/xlint/lint1/stmt_for.c | 16 ++++++++++++++++
tests/usr.bin/xlint/lint1/stmt_for.exp | 2 ++
tests/usr.bin/xlint/lint1/t_integration.sh | 3 ++-
usr.bin/xlint/lint1/func.c | 8 ++++++--
6 files changed, 32 insertions(+), 5 deletions(-)
diffs (108 lines):
diff -r a46540334f2a -r 296a054ae860 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sat Jun 19 19:49:15 2021 +0000
+++ b/distrib/sets/lists/tests/mi Sat Jun 19 19:59:01 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1060 2021/06/19 19:49:15 rillig Exp $
+# $NetBSD: mi,v 1.1061 2021/06/19 19:59:01 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6919,6 +6919,8 @@
./usr/tests/usr.bin/xlint/lint1/msg_344.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/op_colon.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/op_colon.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/stmt_for.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/stmt_for.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/t_integration tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/ztest tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/ztest/Atffile tests-usr.bin-tests compattestfile,atf
diff -r a46540334f2a -r 296a054ae860 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Sat Jun 19 19:49:15 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Sat Jun 19 19:59:01 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.62 2021/06/19 19:49:15 rillig Exp $
+# $NetBSD: Makefile,v 1.63 2021/06/19 19:59:02 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 344 # see lint1/err.c
@@ -134,6 +134,8 @@ FILES+= lex_wide_string.exp
FILES+= ${:U0 ${:U:${:Urange=${MAX_MESSAGE}}}:C,^.$,0&,:C,^..$,0&,:@i@msg_${i}.c msg_${i}.exp@:Nmsg_176.exp}
FILES+= op_colon.c
FILES+= op_colon.exp
+FILES+= stmt_for.c
+FILES+= stmt_for.exp
# ----- begin hack -----
# Prevent that ${DESTDIR}/emit.ln gets ${DESTDIR}/emit.c as implicit source.
diff -r a46540334f2a -r 296a054ae860 tests/usr.bin/xlint/lint1/stmt_for.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/stmt_for.c Sat Jun 19 19:59:01 2021 +0000
@@ -0,0 +1,16 @@
+/* $NetBSD: stmt_for.c,v 1.1 2021/06/19 19:59:02 rillig Exp $ */
+# 3 "stmt_for.c"
+
+/*
+ * Before func.c 1.111 from 2021-06-19, lint ran into an assertion failure:
+ *
+ * "dcs->d_next == NULL" failed in funcend at func.c:422
+ */
+
+void
+test(void)
+{
+ for (0 0; /* expect: syntax error '0' */
+}
+
+/* expect+1: cannot recover from previous errors */
diff -r a46540334f2a -r 296a054ae860 tests/usr.bin/xlint/lint1/stmt_for.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/stmt_for.exp Sat Jun 19 19:59:01 2021 +0000
@@ -0,0 +1,2 @@
+stmt_for.c(13): error: syntax error '0' [249]
+stmt_for.c(17): error: cannot recover from previous errors [224]
diff -r a46540334f2a -r 296a054ae860 tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh Sat Jun 19 19:49:15 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh Sat Jun 19 19:59:01 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.54 2021/06/19 19:49:15 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.55 2021/06/19 19:59:02 rillig Exp $
#
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -182,6 +182,7 @@ test_case lex_string
test_case lex_wide_char
test_case lex_wide_string
test_case op_colon
+test_case stmt_for
all_messages_body()
{
diff -r a46540334f2a -r 296a054ae860 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c Sat Jun 19 19:49:15 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c Sat Jun 19 19:59:01 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.110 2021/06/19 16:05:07 rillig Exp $ */
+/* $NetBSD: func.c,v 1.111 2021/06/19 19:59:02 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.110 2021/06/19 16:05:07 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.111 2021/06/19 19:59:02 rillig Exp $");
#endif
#include <stdlib.h>
@@ -415,6 +415,10 @@ funcend(void)
dcs->d_func_args);
}
+ /* clean up after syntax errors, see test stmt_for.c. */
+ while (dcs->d_next != NULL)
+ dcs = dcs->d_next;
+
/*
* remove all symbols declared during argument declaration from
* the symbol table
Home |
Main Index |
Thread Index |
Old Index