Resolves: fdo#70157 fix crash on loading

Change-Id: I0d248a195852c14cd95d4e337823076dd2fbc19d
(cherry picked from commit 8302d048653d9ac25d3cb9ab9277df715053ad6a)
(cherry picked from commit a757e1b1300dde12fb865c1efd64bfd2bef00e2c)
Reviewed-on: https://gerrit.libreoffice.org/13272
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>