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 handle free-ing of temp symbols properly...



details:   https://anonhg.NetBSD.org/src/rev/e848b5e43aae
branches:  trunk
changeset: 538569:e848b5e43aae
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Oct 22 21:09:34 2002 +0000

description:
handle free-ing of temp symbols properly. Don't segv on bad node types.

diffstat:

 usr.bin/xlint/lint1/init.c |  15 +++++++++++----
 usr.bin/xlint/lint1/scan.l |  11 +++++++++--
 usr.bin/xlint/lint1/tree.c |  13 +++++++++----
 3 files changed, 29 insertions(+), 10 deletions(-)

diffs (122 lines):

diff -r bef21dd3b760 -r e848b5e43aae usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Tue Oct 22 21:02:09 2002 +0000
+++ b/usr.bin/xlint/lint1/init.c        Tue Oct 22 21:09:34 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.13 2002/10/22 13:30:23 christos Exp $       */
+/*     $NetBSD: init.c,v 1.14 2002/10/22 21:09:34 christos Exp $       */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -33,10 +33,11 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.13 2002/10/22 13:30:23 christos Exp $");
+__RCSID("$NetBSD: init.c,v 1.14 2002/10/22 21:09:34 christos Exp $");
 #endif
 
 #include <stdlib.h>
+#include <ctype.h>
 
 #include "lint1.h"
 
@@ -508,7 +509,7 @@
                goto end;
 
        initstk->i_cnt--;
-       DPRINTF(("mkinit() cnt=%d\n", initstk->i_cnt));
+       DPRINTF(("mkinit() cnt=%d tn=%p\n", initstk->i_cnt, tn));
        /* Create a temporary node for the left side. */
        ln = tgetblk(sizeof (tnode_t));
        ln->tn_op = NAME;
@@ -564,7 +565,13 @@
        }
 
  end:
-       tfreeblk();
+       /*
+        * We only free the block, if we are not a compound declaration
+        * We know that the only symbols that start with a digit are the
+        * ones we allocate with mktempsym() for compound declarations
+        */
+       if (!isdigit((unsigned char)initsym->s_name[0]))
+               tfreeblk();
 }
 
 
diff -r bef21dd3b760 -r e848b5e43aae usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Tue Oct 22 21:02:09 2002 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Tue Oct 22 21:09:34 2002 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.29 2002/10/22 18:15:01 christos Exp $ */
+/* $NetBSD: scan.l,v 1.30 2002/10/22 21:09:34 christos 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: scan.l,v 1.29 2002/10/22 18:15:01 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.30 2002/10/22 21:09:34 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -1344,13 +1344,20 @@
 
        (void)snprintf(s, 64, "%.8d_tmp", n++);
        h = hash(s);
+
        sym->s_name = s;
        sym->s_type = t;
        sym->s_blklev = blklev;
        sym->s_scl = AUTO;
+       sym->s_kind = FVFT;
+
        if ((sym->s_link = symtab[h]) != NULL)
                symtab[h]->s_rlink = &sym->s_link;
        (symtab[h] = sym)->s_rlink = &symtab[h];
+
+       *dcs->d_ldlsym = sym;
+       dcs->d_ldlsym = &sym->s_dlnxt;
+
        return sym;
 }
 
diff -r bef21dd3b760 -r e848b5e43aae usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Tue Oct 22 21:02:09 2002 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Tue Oct 22 21:09:34 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.32 2002/10/22 18:15:01 christos Exp $       */
+/*     $NetBSD: tree.c,v 1.33 2002/10/22 21:09:35 christos Exp $       */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.32 2002/10/22 18:15:01 christos Exp $");
+__RCSID("$NetBSD: tree.c,v 1.33 2002/10/22 21:09:35 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -775,10 +775,15 @@
 
        mp = &modtab[op];
 
-       if ((lt = (ltp = ln->tn_type)->t_tspec) == PTR)
+       if ((ltp = ln->tn_type) == NULL)
+               LERROR("typeok()");
+               
+       if ((lt = ltp->t_tspec) == PTR)
                lst = (lstp = ltp->t_subt)->t_tspec;
        if (mp->m_binary) {
-               if ((rt = (rtp = rn->tn_type)->t_tspec) == PTR)
+               if ((rtp = rn->tn_type) == NULL)
+                       LERROR("typeok()");
+               if ((rt = rtp->t_tspec) == PTR)
                        rst = (rstp = rtp->t_subt)->t_tspec;
        }
 



Home | Main Index | Thread Index | Old Index