Fix memory leaks

Change-Id: Id67d5375bedc6e6c10082d9c5ee69d6e932be158
Reviewed-on: https://gerrit.libreoffice.org/9194
Tested-by: David Tardon <dtardon@redhat.com>
Reviewed-by: David Tardon <dtardon@redhat.com>