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 internal error for unfinished ...



details:   https://anonhg.NetBSD.org/src/rev/7466a3885be6
branches:  trunk
changeset: 1021810:7466a3885be6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jun 19 11:01:23 2021 +0000

description:
lint: fix internal error for unfinished declaration

A translation unit that contains just 'void x' without the trailing
semicolon had crashed lint1 before:

assertion "dcs->d_ctx == AUTO" failed in declare at decl.c:2049

Found using afl.

diffstat:

 usr.bin/xlint/lint1/decl.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r d845fea76ab8 -r 7466a3885be6 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sat Jun 19 08:57:24 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sat Jun 19 11:01:23 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.182 2021/05/16 11:11:36 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.183 2021/06/19 11:01:23 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.182 2021/05/16 11:11:36 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.183 2021/06/19 11:01:23 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -3256,6 +3256,8 @@
                 * function declaration
                 */
                return;
+       if (sym->s_def == TDEF && sym->s_type->t_tspec == VOID)
+               return;         /* prevent internal error in length() below */
 
        cpos = curr_pos;
        curr_pos = sym->s_def_pos;



Home | Main Index | Thread Index | Old Index