summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-09-12 20:42:17 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-09-12 21:12:20 +0100
commit70c1cf031dd8179f8eeb33faf842df4d001bf149 (patch)
treeb5917c90e620dd892e447361a611324af549bf0b /oox
parent67f5012d78cabc84a63d232140e34d3658c8c7a0 (diff)
coverity#1323912 Improper use of negative value
Change-Id: I7c403ccb40bfddee2e30ba10e755187490857596
Diffstat (limited to 'oox')
-rw-r--r--oox/source/ole/vbaexport.cxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx
index 904056d6a18d..00880027d836 100644
--- a/oox/source/ole/vbaexport.cxx
+++ b/oox/source/ole/vbaexport.cxx
@@ -630,9 +630,10 @@ void exportModuleStream(SvStream& rStrm, const OUString& rSourceCode, const OUSt
exportString(aModuleStream, "Attribute VB_Name = \"" + aElementName + "\"\r\n");
OUString aSourceCode = rSourceCode.replaceFirst("Option VBASupport 1\n", "");
- sal_Int32 nPos = aSourceCode.indexOf("Rem Attribute VBA_ModuleType=");
- sal_Int32 nEndPos = aSourceCode.indexOf("\n", nPos);
- aSourceCode = aSourceCode.replaceAt(nPos, nEndPos - nPos+1, "");
+ const sal_Int32 nPos = aSourceCode.indexOf("Rem Attribute VBA_ModuleType=");
+ const sal_Int32 nEndPos = nPos != -1 ? aSourceCode.indexOf("\n", nPos) : -1;
+ if (nPos != -1 && nEndPos != -1)
+ aSourceCode = aSourceCode.replaceAt(nPos, nEndPos - nPos+1, "");
aSourceCode = aSourceCode.replaceAll("\n", "\r\n");
exportString(aModuleStream, aSourceCode);
aModuleStream.Seek(0);