From d5d7883fdecfb2c98c880ee2e957a1e34cba45bf Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 27 Sep 2024 08:52:57 +0200 Subject: desktop lok: fix crash in getStyles() Crashreport backtrace: > program/libmergedlo.so > getStyles > desktop/source/lib/init.cxx:6411 > program/libmergedlo.so > doc_getCommandValues > desktop/source/lib/init.cxx:6666 Which is probably a call on an already disposed document. Fix it similar to how getFonts() does it. Change-Id: I1744bd04b7ebdea1b69ca121b8cfa47314d67528 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174372 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- desktop/source/lib/init.cxx | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'desktop/source') diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index d8d217d571ae..043bc769450e 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -6413,6 +6413,10 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) aTree.put("commandName", pCommand); uno::Reference xStyleFamiliesSupplier(pDocument->mxComponent, uno::UNO_QUERY); const uno::Reference xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); + if (!xStyleFamilies.is()) + { + return nullptr; + } const uno::Sequence aStyleFamilies = xStyleFamilies->getElementNames(); static constexpr OUString aWriterStyles[] = -- cgit