diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2015-08-03 16:24:10 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2015-08-03 16:24:10 -0700 |
commit | ea3133e3a4163a133e0c26aea8c905caa156a752 (patch) | |
tree | 66bd2b404b786abd71e8af7ca1983c026e134d8a /src/base/wlc | |
parent | b29cda081ad9b728578d35bec58f032554588c4b (diff) | |
download | abc-ea3133e3a4163a133e0c26aea8c905caa156a752.tar.gz abc-ea3133e3a4163a133e0c26aea8c905caa156a752.tar.bz2 abc-ea3133e3a4163a133e0c26aea8c905caa156a752.zip |
Making ABC error out instead of crashing when non-standard range is given.
Diffstat (limited to 'src/base/wlc')
-rw-r--r-- | src/base/wlc/wlcReadVer.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/base/wlc/wlcReadVer.c b/src/base/wlc/wlcReadVer.c index 72844917..64658e05 100644 --- a/src/base/wlc/wlcReadVer.c +++ b/src/base/wlc/wlcReadVer.c @@ -493,6 +493,8 @@ static inline char * Wlc_PrsFindRange( char * pStr, int * End, int * Beg ) if ( pStr == NULL ) return NULL; } + if ( *End < *Beg ) + return NULL; assert( *End >= *Beg ); return pStr + 1; } @@ -748,8 +750,10 @@ static inline int Wlc_PrsFindDefinition( Wlc_Prs_t * p, char * pStr, Vec_Int_t * } else if ( pStr[0] == '[' ) { - int End, Beg; + int End, Beg; char * pLine = pStr; pStr = Wlc_PrsFindRange( pStr, &End, &Beg ); + if ( pStr == NULL ) + return Wlc_PrsWriteErrorMessage( p, pLine, "Non-standard range." ); Vec_IntPush( vFanins, (End << 16) | Beg ); Type = WLC_OBJ_BIT_SELECT; } @@ -795,7 +799,7 @@ static inline int Wlc_PrsFindDefinition( Wlc_Prs_t * p, char * pStr, Vec_Int_t * } int Wlc_PrsReadDeclaration( Wlc_Prs_t * p, char * pStart ) { - int fFound = 0, Type = WLC_OBJ_NONE, iObj; + int fFound = 0, Type = WLC_OBJ_NONE, iObj; char * pLine; int Signed = 0, Beg = 0, End = 0, NameId, fIsPo = 0; if ( Wlc_PrsStrCmp( pStart, "input" ) ) pStart += strlen("input"), Type = WLC_OBJ_PI; @@ -809,9 +813,10 @@ int Wlc_PrsReadDeclaration( Wlc_Prs_t * p, char * pStart ) // read 'signed' pStart = Wlc_PrsFindWord( pStart, "signed", &Signed ); // read range + pLine = pStart; pStart = Wlc_PrsFindRange( pStart, &End, &Beg ); if ( pStart == NULL ) - return Wlc_PrsWriteErrorMessage( p, pStart, "Cannot read range." ); + return Wlc_PrsWriteErrorMessage( p, pLine, "Non-standard range." ); if ( Beg != 0 ) { if ( p->nNonZeroCount++ == 0 ) |