coverity#1222240 Untrusted value as argument

and

coverity#1222239 Untrusted value as argument

(cherry picked from commit 5e043613266113a873c55ad45ab0fb1ae14286e8)

Change-Id: I48bacfd988a34d67ffa542edba7cba1bb9b0b3cc
Reviewed-on: https://gerrit.libreoffice.org/10050
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>