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: replace crash with assertion failure



details:   https://anonhg.NetBSD.org/src/rev/858e8eb7d88e
branches:  trunk
changeset: 364619:858e8eb7d88e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Apr 01 01:06:26 2022 +0000

description:
lint: replace crash with assertion failure

Triggered by 'sizeof(int())'.

GCC evaluates this expression to 1, without any warning.

Clang warns about an "invalid application of 'sizeof' to a function
type".

diffstat:

 usr.bin/xlint/lint1/tree.c |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diffs (26 lines):

diff -r 0807e700a304 -r 858e8eb7d88e usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Fri Apr 01 01:00:39 2022 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Fri Apr 01 01:06:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.411 2022/03/13 15:26:54 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.412 2022/04/01 01:06:26 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.411 2022/03/13 15:26:54 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.412 2022/04/01 01:06:26 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -3473,6 +3473,7 @@
 
        elem = 1;
        flex = false;
+       lint_assert(tp != NULL);
        while (tp->t_tspec == ARRAY) {
                flex = true;    /* allow c99 flex arrays [] [0] */
                elem *= tp->t_dim;



Home | Main Index | Thread Index | Old Index