From 7a1ab3f0a3c4545b35cf4cc4e3d71b791053350d Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Mon, 18 Nov 2024 21:03:10 +0100 Subject: [PATCH] tdf#163486: PVS: reference may become invalid V758 The 'aModel' reference becomes invalid when smart pointer returned by a function is destroyed. Change-Id: If06b81fda6fdaf4debf5061dd0e3c6c7caccad5a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176742 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- oox/source/drawingml/chart/typegroupconverter.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/oox/source/drawingml/chart/typegroupconverter.cxx b/oox/source/drawingml/chart/typegroupconverter.cxx index 7a8a506af82b..9127e7d47006 100644 --- a/oox/source/drawingml/chart/typegroupconverter.cxx +++ b/oox/source/drawingml/chart/typegroupconverter.cxx @@ -303,16 +303,17 @@ Reference< XLabeledDataSequence > TypeGroupConverter::createCategorySequence() if( !xLabeledSeq.is() && !mrModel.maSeries.empty() ) { if( nMaxValues < 0 ) nMaxValues = 2; - SeriesModel &aModel = *mrModel.maSeries.get(0); - if (!aModel.maSources.has(SeriesModel::CATEGORIES)) + typedef RefVector SeriesModelVector; + SeriesModelVector::value_type aModel = mrModel.maSeries.get(0); + if (!aModel->maSources.has(SeriesModel::CATEGORIES)) { - DataSourceModel &aSrc = aModel.maSources.create( SeriesModel::CATEGORIES ); + DataSourceModel &aSrc = aModel->maSources.create( SeriesModel::CATEGORIES ); DataSequenceModel &aSeq = aSrc.mxDataSeq.create(); aSeq.mnPointCount = nMaxValues; for( sal_Int32 i = 0; i < nMaxValues; i++ ) aSeq.maData[ i ] <<= OUString::number( i + 1 ); } - SeriesConverter aSeriesConv( *this, aModel ); + SeriesConverter aSeriesConv( *this, *aModel ); xLabeledSeq = aSeriesConv.createCategorySequence( u"categories"_ustr ); } return xLabeledSeq;