Fixed for libreoffice crashes while opening file.

Change-Id: I85a16e4ef8d75f19250115d5522046a968d5fc91
Reviewed-on: https://gerrit.libreoffice.org/6760
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit c6e333e73b811a65526628effb21636f4f420cc5)