diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-05-28 14:30:25 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-05-28 14:34:13 +0200 |
commit | 145b64c4eb0a335d4290e998c78ca8280a5004a3 (patch) | |
tree | 3c2cd5cb1d3c3ffa42f795bd9d234165ad6bd0b3 /basic | |
parent | a77a7f608316f647ed8736e9474ff8f4f432f08b (diff) |
Avoid undefined signed integer overflow
Change-Id: I3f32ea88dbb34a05baccba49c15b6691d923753e
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/comp/scanner.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx index fd6ff11d9565..042518d394f4 100644 --- a/basic/source/comp/scanner.cxx +++ b/basic/source/comp/scanner.cxx @@ -439,7 +439,7 @@ bool SbiScanner::NextSym() bNumber = true; // Hex literals are signed Integers ( as defined by basic // e.g. -2,147,483,648 through 2,147,483,647 (signed) - sal_Int32 l = 0; + sal_uInt32 lu = 0; int i; bool bBufOverflow = false; while(nCol < aLine.getLength() && theBasicCharClass::get().isAlphaNumeric(aLine[nCol] & 0xFF, bCompatible)) @@ -463,15 +463,16 @@ bool SbiScanner::NextSym() { i = (*p & 0xFF) - '0'; if( i > 9 ) i -= 7; - l = ( l * base ) + i; + lu = ( lu * base ) + i; if( !ndig-- ) { GenError( SbERR_MATH_OVERFLOW ); break; } } if(nCol < aLine.getLength() && aLine[nCol] == '&') ++pLine, ++nCol; - nVal = (double) l; - eScanType = ( l >= SbxMININT && l <= SbxMAXINT ) ? SbxINTEGER : SbxLONG; + sal_Int32 ls = static_cast<sal_Int32>(lu); + nVal = (double) ls; + eScanType = ( ls >= SbxMININT && ls <= SbxMAXINT ) ? SbxINTEGER : SbxLONG; if( bBufOverflow ) GenError( SbERR_MATH_OVERFLOW ); } |