n#839727 / rhbz#1038176 Crash fix

(cherry picked from commit e5f24e0c7c8f4799223c19359f4228f0b1a71461)

Change-Id: I8d733afbbc05900c68217ead44de798c1263ca84
Reviewed-on: https://gerrit.libreoffice.org/7309
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>