summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-12-07 16:37:13 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-12-07 21:22:28 +0100
commit05f97ef127ec6ee0cc159fc74b4fecc34d9c684c (patch)
treea86b48b0371210f669a1f9095fcbf46c2a941c79 /sc
parenta9a4c26ed1365ffa089654fefc8fa2f29862b6c7 (diff)
coverity#1425723 silence 'Wrapper object use after free'
Change-Id: Ibcc0e5f28910bdd15c94579d754de3698ac8beb1 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>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/xml/xmlcondformat.cxx17
1 files changed, 10 insertions, 7 deletions
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index 1d2cab79dd76..4925563b1502 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -325,7 +325,16 @@ void SAL_CALL ScXMLConditionalFormatContext::endFastElement( sal_Int32 /*nElemen
}
}
}
+ }
+
+ 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;
@@ -337,17 +346,11 @@ void SAL_CALL ScXMLConditionalFormatContext::endFastElement( sal_Int32 /*nElemen
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()