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 Prevent use of stale pointer for determi...



details:   https://anonhg.NetBSD.org/src/rev/bd4ae100d893
branches:  trunk
changeset: 547448:bd4ae100d893
user:      kristerw <kristerw%NetBSD.org@localhost>
date:      Sun May 18 23:30:00 2003 +0000

description:
Prevent use of stale pointer for determining return type of ({ })
expressions.

Details:
lint did fail on constructs like

   struct foo *x;
   x = ({ struct foo *y; /* do stuff */; y;});

since it gave the whole ({ }) the same structure representing the
type as y, but that structure is reclaimed when y goes out of scope.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 05d69b57053a -r bd4ae100d893 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sun May 18 22:11:31 2003 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun May 18 23:30:00 2003 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.30 2002/10/23 13:01:16 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.31 2003/05/18 23:30:00 kristerw Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.30 2002/10/23 13:01:16 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.31 2003/05/18 23:30:00 kristerw Exp $");
 #endif
 
 #include <stdlib.h>
@@ -1568,7 +1568,7 @@
        | T_LPARN comp_stmnt_lbrace declaration_list expr_stmnt_list {
                blklev--;
                mblklev--;
-               initsym = mktempsym($4->tn_type);
+               initsym = mktempsym(duptyp($4->tn_type));
                mblklev++;
                blklev++;
                gnuism(320);



Home | Main Index | Thread Index | Old Index