Module Name:    src
Committed By:   rillig
Date:           Sun Jun 20 11:00:18 UTC 2021

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

Log Message:
lint: fix segmentation fault for malformed struct

Code to trigger this bug: struct{char a(_)0}

Found using afl.


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 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.186 src/usr.bin/xlint/lint1/decl.c:1.187
--- src/usr.bin/xlint/lint1/decl.c:1.186	Sat Jun 19 15:51:11 2021
+++ src/usr.bin/xlint/lint1/decl.c	Sun Jun 20 11:00:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.186 2021/06/19 15:51:11 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.187 2021/06/20 11:00:18 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.186 2021/06/19 15:51:11 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.187 2021/06/20 11:00:18 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -198,6 +198,7 @@ setcomplete(type_t *tp, bool complete)
 {
 	tspec_t	t;
 
+	lint_assert(tp != NULL);
 	if ((t = tp->t_tspec) == ARRAY) {
 		tp->t_incomplete_array = !complete;
 	} else if (t == STRUCT || t == UNION) {

Reply via email to