diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-03-04 10:38:50 +0000 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-04-01 14:51:13 +0200 |
commit | daa2b51b1ba58148f7c2a72a5e7272bac6067423 (patch) | |
tree | 429364869eb92557c30513b80f265d511fd673bf | |
parent | protect frame from triggering deleting itself (diff) | |
download | core-daa2b51b1ba58148f7c2a72a5e7272bac6067423.tar.gz core-daa2b51b1ba58148f7c2a72a5e7272bac6067423.zip |
clamp and add some logging like SvmReader
LIBREOFFICE-OWMTGGWJ
Change-Id: I8f744e1ab2684a0f0995abcc3e753a684a3b970a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130982
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 19add15932e579c931480eed42eeea52d0551897)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131369
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 8727f47611af8dfb5ac186cc47e7b38741ccfb76)
-rw-r--r-- | vcl/source/gdi/svmconverter.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/vcl/source/gdi/svmconverter.cxx b/vcl/source/gdi/svmconverter.cxx index 71c7c5c7b26f..6721ceb9df8a 100644 --- a/vcl/source/gdi/svmconverter.cxx +++ b/vcl/source/gdi/svmconverter.cxx @@ -239,6 +239,23 @@ namespace nFollowingActionCount = remainingActions; return std::min(remainingActions, nFollowingActionCount); } + + void ClampRange(const OUString& rStr, sal_Int32& rIndex, sal_Int32& rLength) + { + const sal_Int32 nStrLength = rStr.getLength(); + + if (rIndex < 0 || rIndex > nStrLength) + { + SAL_WARN("vcl.gdi", "inconsistent offset"); + rIndex = nStrLength; + } + + if (rLength < 0 || rLength > nStrLength - rIndex) + { + SAL_WARN("vcl.gdi", "inconsistent len"); + rLength = nStrLength - rIndex; + } + } } #define LF_FACESIZE 32 @@ -680,6 +697,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) OUString aStr(OStringToOUString(aByteStr, eActualCharSet)); if ( nUnicodeCommentActionNumber == i ) ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr ); + ClampRange(aStr, nIndex, nLen); rMtf.AddAction( new MetaTextAction( aPt, aStr, nIndex, nLen ) ); } @@ -770,6 +788,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) } if ( nUnicodeCommentActionNumber == i ) ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr ); + ClampRange(aStr, nIndex, nLen); rMtf.AddAction( new MetaTextArrayAction( aPt, aStr, pDXAry.get(), nIndex, nLen ) ); } @@ -795,6 +814,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) OUString aStr(OStringToOUString(aByteStr, eActualCharSet)); if ( nUnicodeCommentActionNumber == i ) ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr ); + ClampRange(aStr, nIndex, nLen); rMtf.AddAction( new MetaStretchTextAction( aPt, nWidth, aStr, nIndex, nLen ) ); } |