[Libreoffice-commits] core.git: svtools/source
Stephan Bergmann
sbergman at redhat.com
Tue Jan 27 07:48:37 PST 2015
svtools/source/brwbox/datwin.cxx | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
New commits:
commit 7d7c7c44e52814acdad39c6e92e53fd332c1e683
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Jan 27 16:43:22 2015 +0100
UBSan-detected overflow when nWidthPixel is LONG_MAX and rCurrentZoom is 1
...from the call to
SetColumnWidth( nId, LONG_MAX );
in BrowseBox::AutoSizeLastColumn(), e.g. happens when opening the Gallery in
Draw.
Change-Id: I151ae557d9d2bec52ecb0bd92b870fb0b91d7242
diff --git a/svtools/source/brwbox/datwin.cxx b/svtools/source/brwbox/datwin.cxx
index a3dd140..e56ef6b 100644
--- a/svtools/source/brwbox/datwin.cxx
+++ b/svtools/source/brwbox/datwin.cxx
@@ -124,12 +124,21 @@ BrowserColumn::~BrowserColumn()
void BrowserColumn::SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom)
{
_nWidth = nNewWidthPixel;
- double n = (double)_nWidth;
- n *= (double)rCurrentZoom.GetDenominator();
- if (!rCurrentZoom.GetNumerator())
- throw o3tl::divide_by_zero();
- n /= (double)rCurrentZoom.GetNumerator();
- _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
+ // Avoid overflow when called with LONG_MAX from
+ // BrowseBox::AutoSizeLastColumn:
+ if (_nWidth == LONG_MAX)
+ {
+ _nOriginalWidth = _nWidth;
+ }
+ else
+ {
+ double n = (double)_nWidth;
+ n *= (double)rCurrentZoom.GetDenominator();
+ if (!rCurrentZoom.GetNumerator())
+ throw o3tl::divide_by_zero();
+ n /= (double)rCurrentZoom.GetNumerator();
+ _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
+ }
}
void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, bool bCurs )
More information about the Libreoffice-commits
mailing list