svx/source/gallery2/galbrws1.cxx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
New commits: commit 3a0c79aace5b93b597d827485da87b10d0d6cecc Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Sat Sep 7 17:59:26 2024 +0200 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sat Sep 7 21:14:59 2024 +0200 svx: fix Dereference before null check Seen in https://crashreport.libreoffice.org/stats/signature/GalleryBrowser1::FillThemeEntries() Regression from commit 09c6204b6309321aa25c542f918fde9f5f3f7fe2 Author: Oliver Specht <oliver.spe...@cib.de> Date: Thu Feb 29 17:15:23 2024 +0100 tdf#81880 Search the Gallery Change-Id: I4c19920b5f7a56fff37587cd1acf579f3a96ae4c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172997 Tested-by: Jenkins Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/svx/source/gallery2/galbrws1.cxx b/svx/source/gallery2/galbrws1.cxx index 4aeb69fbb2df..14d2e841e4e0 100644 --- a/svx/source/gallery2/galbrws1.cxx +++ b/svx/source/gallery2/galbrws1.cxx @@ -1497,17 +1497,19 @@ void GalleryBrowser1::FillThemeEntries() const GalleryThemeEntry* pThemeInfo = mpGallery->GetThemeInfo( i ); OUString aThemeName = pThemeInfo->GetThemeName(); //sal_uInt32 nId = pThemeInfo->GetId(); - GalleryTheme* pTheme = mpGallery->AcquireTheme(aThemeName, maLocalListner); - sal_uInt32 nObjectCount = pTheme->GetObjectCount(); - for (size_t nObject = 0; nObject < nObjectCount; ++nObject) + if (GalleryTheme* pTheme = mpGallery->AcquireTheme(aThemeName, maLocalListner)) { - if (std::unique_ptr<SgaObject> xSgaObject = pTheme->AcquireObject(nObject)) + sal_uInt32 nObjectCount = pTheme->GetObjectCount(); + for (size_t nObject = 0; nObject < nObjectCount; ++nObject) { - OUString aTitle = GetItemText(*xSgaObject, GalleryItemFlags::Title); - maAllThemeEntries.push_back(ThemeEntry(aThemeName, aTitle, nObject)); + if (std::unique_ptr<SgaObject> xSgaObject = pTheme->AcquireObject(nObject)) + { + OUString aTitle = GetItemText(*xSgaObject, GalleryItemFlags::Title); + maAllThemeEntries.push_back(ThemeEntry(aThemeName, aTitle, nObject)); + } } + mpGallery->ReleaseTheme(pTheme, maLocalListner); } - mpGallery->ReleaseTheme(pTheme, maLocalListner); } maFoundThemeEntries.assign(maAllThemeEntries.begin(), maAllThemeEntries.end()); }