diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-10-24 14:46:32 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-10-25 16:00:08 +0200 |
commit | ffb19c5be464770e6ac2d9b13422353c8a03294b (patch) | |
tree | 6b5cdb8ca4c9263a94196e3995ed097d2a621e62 /sax | |
parent | 4eb288ad1d6373a5374884118bd2344b739d8f9a (diff) |
ofz#3752 Integer-overflow
Change-Id: I211327928a86f706513ebd78cff979283396e742
Reviewed-on: https://gerrit.libreoffice.org/43777
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sax')
-rw-r--r-- | sax/source/tools/converter.cxx | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx index 1cb8cf190f04..d2a84cd8ea7d 100644 --- a/sax/source/tools/converter.cxx +++ b/sax/source/tools/converter.cxx @@ -543,9 +543,6 @@ bool Converter::convertNumber64( sal_Int64& rValue, const OUString& rString, sal_Int64 nMin, sal_Int64 nMax ) { - bool bNeg = false; - rValue = 0; - sal_Int32 nPos = 0; sal_Int32 const nLen = rString.getLength(); @@ -553,10 +550,11 @@ bool Converter::convertNumber64( sal_Int64& rValue, while( (nPos < nLen) && (rString[nPos] <= ' ') ) nPos++; + OUStringBuffer sNumber; + if( nPos < nLen && '-' == rString[nPos] ) { - bNeg = true; - nPos++; + sNumber.append(rString[nPos++]); } // get number @@ -564,14 +562,10 @@ bool Converter::convertNumber64( sal_Int64& rValue, '0' <= rString[nPos] && '9' >= rString[nPos] ) { - // TODO: check overflow! - rValue *= 10; - rValue += (rString[nPos] - u'0'); - nPos++; + sNumber.append(rString[nPos++]); } - if( bNeg ) - rValue *= -1; + rValue = sNumber.toString().toInt64(); if( rValue < nMin ) rValue = nMin; |