[Libreoffice-commits] core.git: sc/source
Caolán McNamara
caolanm at redhat.com
Thu Dec 7 20:24:14 UTC 2017
sc/source/filter/xml/xmlcondformat.cxx | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
New commits:
commit 05f97ef127ec6ee0cc159fc74b4fecc34d9c684c
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Dec 7 16:37:13 2017 +0000
coverity#1425723 silence 'Wrapper object use after free'
Change-Id: Ibcc0e5f28910bdd15c94579d754de3698ac8beb1
Reviewed-on: https://gerrit.libreoffice.org/46035
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
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()
More information about the Libreoffice-commits
mailing list