From 17181dfd0ff3abed78f00b5812e9652a8344bab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Mon, 26 Aug 2024 21:06:26 +0100 Subject: [PATCH] cid#1606906 Overflowed constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8ac1aabb50c5ef061b8ac359cb9d7ce8fe66c62c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172511 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- vcl/source/treelist/imap2.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/vcl/source/treelist/imap2.cxx b/vcl/source/treelist/imap2.cxx index c49aa45b5e6e..559658581ca5 100644 --- a/vcl/source/treelist/imap2.cxx +++ b/vcl/source/treelist/imap2.cxx @@ -416,12 +416,17 @@ void ImageMap::ImpReadNCSALine( std::string_view rLine ) } else if ( aToken == "poly" ) { - const sal_uInt16 nCount = comphelper::string::getTokenCount(aStr, ',') - 1; + const sal_Int32 nTokenCount = comphelper::string::getTokenCount(aStr, ','); const OUString aURL( ImpReadNCSAURL( &pStr ) ); - tools::Polygon aPoly( nCount ); + tools::Polygon aPoly; + if (nTokenCount > 0) + { + const sal_uInt16 nCount = nTokenCount - 1; + aPoly.SetSize(nCount); - for ( sal_uInt16 i = 0; i < nCount; i++ ) - aPoly[ i ] = ImpReadNCSACoords( &pStr ); + for (sal_uInt16 i = 0; i < nCount; ++i) + aPoly[ i ] = ImpReadNCSACoords( &pStr ); + } maList.emplace_back( new IMapPolygonObject( aPoly, aURL, OUString(), OUString(), OUString(), OUString() ) ); }