[hackers] [scc] [cc2] fix symbol hashing of TMPSYM || Quentin Rameau

From: <git_AT_suckless.org>
Date: Thu, 3 Nov 2016 14:23:46 +0100 (CET)

commit bc267b974204cd6ddf6f717a0a2597dc33f68406
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Thu Oct 27 14:17:40 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Thu Nov 3 11:45:55 2016 +0100

    [cc2] fix symbol hashing of TMPSYM
    
    As TMPSYM is a dummy id, we would always use the same hash for temporary
    symbols ending up in a segfault or infinite loop.
    
    Thanks to k0ga for finding a better fix than mine.

diff --git a/cc2/symbol.c b/cc2/symbol.c
index 9b1fdbc..3c0723c 100644
--- a/cc2/symbol.c
+++ b/cc2/symbol.c
_AT_@ -38,7 +38,8 @@ popctx(void)
         infunction = 0;
         for (sym = locals; sym; sym = next) {
                 next = sym->next;
- symtab[sym->id & NR_SYMHASH-1] = sym->h_next;
+ if (sym->id != TMPSYM)
+ symtab[sym->id & NR_SYMHASH-1] = sym->h_next;
                 freesym(sym);
         }
         curlocal = locals = NULL;
_AT_@ -70,8 +71,10 @@ getsym(unsigned id)
                                 curlocal->next = sym;
                         curlocal = sym;
                 }
- sym->h_next = *htab;
- *htab = sym;
+ if (id != TMPSYM) {
+ sym->h_next = *htab;
+ *htab = sym;
+ }
         }
         return sym;
 }
Received on Thu Nov 03 2016 - 14:23:46 CET

This archive was generated by hypermail 2.3.0 : Thu Nov 03 2016 - 14:24:28 CET