Module Name:    src
Committed By:   rillig
Date:           Sat Jun 19 11:01:23 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: decl.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/usr.bin/xlint/lint1/decl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.182 src/usr.bin/xlint/lint1/decl.c:1.183
--- src/usr.bin/xlint/lint1/decl.c:1.182	Sun May 16 11:11:36 2021
+++ src/usr.bin/xlint/lint1/decl.c	Sat Jun 19 11:01:23 2021
@@ -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 @@ check_global_variable_size(const sym_t *
 		 * 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;

Reply via email to