Ignore:
Timestamp:
Jan 8, 2015, 2:37:47 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, resolv-new, string, with_gc
Children:
6c3744e
Parents:
17cd4eb
Message:

fix uninitialized value, fix memory reads after frees

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/Parser/TypedefTable.cc

    r17cd4eb r0b8cd72  
    106106void TypedefTable::leaveScope(void) {
    107107    debugPrint( "Leaving scope " << currentScope << endl );
    108     for (tableType::iterator i = table.begin(); i != table.end(); i++) {
     108    for (tableType::iterator i = table.begin(); i != table.end(); ) {
    109109        list<Entry> &declList = (*i).second;
    110110        while (!declList.empty() && declList.front().scope == currentScope) {
    111111            declList.pop_front();
    112112        }
    113         if ( declList.empty() ) {
    114             table.erase( i );
    115         }
     113        if ( declList.empty() ) {                       // standard idom for erasing during traversal
     114            table.erase( i++ );
     115        } else ++i;
    116116    }
    117117    currentScope -= 1;
Note: See TracChangeset for help on using the changeset viewer.