Changeset 0b8cd72


Ignore:
Timestamp:
Jan 8, 2015, 2:37:47 PM (7 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, resolv-new, string, with_gc
Children:
6c3744e
Parents:
17cd4eb
Message:

fix uninitialized value, fix memory reads after frees

Location:
translator
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • translator/Parser/InitializerNode.cc

    r17cd4eb r0b8cd72  
    2020
    2121InitializerNode::InitializerNode( InitializerNode *init, bool aggrp, ExpressionNode *des )
    22         : aggregate( aggrp ), designator( des ), kids( 0 ) {
     22    : expr( 0 ), aggregate( aggrp ), designator( des ), kids( 0 ) {
    2323    if ( init != 0 )
    2424        set_link(init);
  • translator/Parser/TypeData.cc

    r17cd4eb r0b8cd72  
    3333        function->body = 0;
    3434        function->hasBody = false;
     35        function->newStyle = false;
    3536        break;
    3637      case Aggregate:
  • 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;
  • translator/examples/swap.c

    r17cd4eb r0b8cd72  
    44
    55forall( type T )
    6 T swap( T *left, T *right ) {
     6void swap( T *left, T *right ) {
    77    T temp;
    88    temp = *left;
    99    *left = *right;
    1010    *right = temp;
    11     return *right;
    1211}
    1312
     
    1514    int x = 1, y = 2;
    1615    printf( "%d %d\n", x, y );
    17     int w;
    18     w = swap( &x, &y );
    19     printf( "%d %d %d\n", w, x, y );
     16    swap( &x, &y );
     17    printf( "%d %d\n", x, y );
    2018}
    2119
Note: See TracChangeset for help on using the changeset viewer.