[hackers] [scc] popctx: fix symbol check, only add to table if sym->name is set || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sat, 18 Jul 2015 20:03:54 +0200 (CEST)

commit d5065baafed6ee455fc43471085b899d6cf614a0
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Sat Jul 18 20:02:05 2015 +0200
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Sat Jul 18 20:02:05 2015 +0200

    popctx: fix symbol check, only add to table if sym->name is set
    
    this crashed (same parameter name), reproduce:
    
    printf '#define t(n) 1\n#define t2(n) 2' | ./cc1

diff --git a/cc1/symbol.c b/cc1/symbol.c
index c8b3487..f609e13 100644
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
_AT_@ -87,7 +87,7 @@ popctx(void)
                         sym->type->defined = 0;
                         break;
                 }
- if (sym->hash)
+ if (sym->name)
                         htab[hash(sym->name)] = sym->hash;
                 free(sym->name);
                 free(sym);
Received on Sat Jul 18 2015 - 20:03:54 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 18 2015 - 20:12:11 CEST