diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-12-07 16:37:13 +0000 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2018-04-24 08:35:37 +0200 |
commit | 7ab0ddd29fa404ff4bcdf0159de8820fa0c147ff (patch) | |
tree | f7f98c5c71c99f1c2922a2ab618efc8d33d4dccd | |
parent | Don't leak formats that get merged (diff) | |
download | core-7ab0ddd29fa404ff4bcdf0159de8820fa0c147ff.tar.gz core-7ab0ddd29fa404ff4bcdf0159de8820fa0c147ff.zip |
coverity#1425723 silence 'Wrapper object use after free'
Reviewed-on: https://gerrit.libreoffice.org/46035
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 05f97ef127ec6ee0cc159fc74b4fecc34d9c684c)
Change-Id: Ibcc0e5f28910bdd15c94579d754de3698ac8beb1
-rw-r--r-- | sc/source/filter/xml/xmlcondformat.cxx | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx index f87b077d2436..3917e25f1cb0 100644 --- a/sc/source/filter/xml/xmlcondformat.cxx +++ b/sc/source/filter/xml/xmlcondformat.cxx @@ -324,7 +324,16 @@ void ScXMLConditionalFormatContext::EndElement() } } } + } + + sal_uLong nIndex = pDoc->AddCondFormat(pFormat.release(), nTab); + ScConditionalFormat* pInsertedFormat = pDoc->GetCondFormList(nTab)->GetFormat(nIndex); + assert(pInsertedFormat && pInsertedFormat->GetKey() == nIndex); + mrParent.mvCondFormatData.push_back( { pInsertedFormat, nTab } ); + + if (bEligibleForCache) + { // Not found in cache, replace oldest cache entry sal_Int64 nOldestAge = -1; size_t nIndexOfOldest = 0; @@ -336,17 +345,11 @@ void ScXMLConditionalFormatContext::EndElement() nIndexOfOldest = (&aCacheEntry - &mrParent.maCache.front()); } } - mrParent.maCache[nIndexOfOldest].mpFormat = pFormat.get(); + mrParent.maCache[nIndexOfOldest].mpFormat = pInsertedFormat; mrParent.maCache[nIndexOfOldest].mbSingleRelativeReference = bSingleRelativeReference; mrParent.maCache[nIndexOfOldest].mpTokens.reset(pTokens); mrParent.maCache[nIndexOfOldest].mnAge = 0; } - - sal_uLong nIndex = pDoc->AddCondFormat(pFormat.get(), nTab); - (void) nIndex; // Avoid 'unused variable' warning when assert() expands to empty - assert(pFormat->GetKey() == nIndex); - - mrParent.mvCondFormatData.push_back( { pFormat.release(), nTab } ); } ScXMLConditionalFormatContext::~ScXMLConditionalFormatContext() |