Changeset 153 for trunk/orca/ovalue.c

Show
Ignore:
Timestamp:
05/14/06 04:07:39 (3 years ago)
Author:
krobillard
Message:

Fixed uninitialized memory in orSetError().
orMake() & orToNative() no longer set new value type until after GC might run.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/orca/ovalue.c

    r148 r153  
    650650static int orMake( int type, OValue* from, OValue* res ) 
    651651{ 
    652     orSetTF( res, type ); 
    653  
    654652    switch( type ) 
    655653    { 
     
    667665                orIntern( &ctx, str->charArray + start, 
    668666                          str->used - start, res ); 
     667                orSetTF( res, type ); 
    669668                return 1; 
    670669            } 
    671670            else if( orIs(from, OT_WORD) ) 
    672671            { 
     672                orSetTF( res, type ); 
    673673                res->word = from->word; 
    674674                return 1; 
     
    693693            if( orIs(from, OT_LOGIC) ) 
    694694            { 
     695                orSetTF( res, type ); 
    695696                orInt(res) = orInt(from); 
    696697                return 1; 
     
    698699            else if( orIs(from, OT_DECIMAL) ) 
    699700            { 
     701                orSetTF( res, type ); 
    700702                orInt(res) = (int) orDecimal(from); 
    701703                return 1; 
     
    707709                char* end = str->charArray + str->used; 
    708710                const char* fin; 
    709                 orInt(res) = orStringToInt( it, end, &fin ); 
     711                int n; 
     712                n = orStringToInt( it, end, &fin ); 
    710713                if( fin == end ) 
     714                { 
     715                    orSetTF( res, type ); 
     716                    orInt(res) = n; 
    711717                    return 1; 
     718                } 
    712719            } 
    713720            break; 
     
    717724                orIs(from, OT_LOGIC) ) 
    718725            { 
     726                orSetTF( res, type ); 
    719727                orDecimal(res) = (double) orInt(from); 
    720728                return 1; 
     
    726734                char* end = str->charArray + str->used; 
    727735                const char* fin; 
    728                 orDecimal(res) = orStringToDec( it, end, &fin ); 
     736                double n; 
     737                n = orStringToDec( it, end, &fin ); 
    729738                if( fin == end ) 
     739                { 
     740                    orSetTF( res, type ); 
     741                    orDecimal(res) = n; 
    730742                    return 1; 
     743                } 
    731744            } 
    732745            break; 
     
    769782                    if( it == end ) 
    770783                    { 
     784                        orSetTF( res, OT_TUPLE ); 
    771785                        res->argc = tuple - res->tuple; 
    772786                        return 1; 
     
    979993 
    980994    res = a1; 
    981     orSetTF( res, type ); 
    982995 
    983996    if( orIsBlock(type) ) 
     
    985998        if( orIsBlock(a2->type) ) 
    986999        { 
     1000            orSetTF( res, type ); 
    9871001            res->series = a2->series; 
    9881002            return; 
     
    9921006        { 
    9931007            OBlock* blk = orMakeBlock( 3 ); 
     1008            orSetTF( res, type ); 
    9941009            orSetSeries( res, orBlockN(blk), 0 ); 
    9951010            orAppendDecimal( blk, a2->vec3.x ); 
     
    10031018            OString* arr = orSTRING(a2); 
    10041019            OBlock* blk = orMakeBlock( 16 ); 
     1020            orSetTF( res, type ); 
    10051021            orSetSeries( res, orBlockN(blk), 0 ); 
    10061022            for( i = 0; i < 16; ++i ) 
     
    10141030            OBinary* bin = orSTRINGS + a2->index; 
    10151031            OBlock* blk = orMakeBlock( 0 ); 
     1032            orSetTF( res, type ); 
    10161033            orSetSeries( res, orBlockN(blk), 0 ); 
    10171034 
     
    10331050            blk->used = 1; 
    10341051 
     1052            orSetTF( res, type ); 
    10351053            orSetSeries( res, blk - orBLOCKS, 0 ); 
    10361054            return; 
     
    10411059        if( orIsString(a2->type) ) 
    10421060        { 
     1061            orSetTF( res, type ); 
    10431062            res->series = a2->series; 
    10441063            return; 
     
    10521071 
    10531072            str = orMakeString( 0 ); 
     1073            orSetTF( res, type ); 
    10541074            orSetSeries( res, str - orSTRINGS, 0 ); 
    10551075 
     
    10651085            OString* str = orMakeString( 0 ); 
    10661086            orForm( str, a2 ); 
     1087            orSetTF( res, type ); 
    10671088            orSetSeries( res, str - orSTRINGS, 0 ); 
    10681089            return; 
     
    10751096        { 
    10761097            OBinary* bin = orMakeBinary( 0 ); 
     1098            orSetTF( res, type ); 
    10771099            orSetSeries( res, orBinaryN(bin), 0 ); 
    10781100            orCompileByteCodes( bin, a2 ); 
     
    17561778    orSetTF( val, OT_ERROR ); 
    17571779    val->argc = type;      
     1780    val->error.block = 0;   // Init for orSetErrorLoc(). 
    17581781 
    17591782    orEnv->error = val;