scripting: avoid a possible NullPointerException

Change-Id: I90589bc042f4b88b700e9f3c167c460c3cff043c
Reviewed-on: https://gerrit.libreoffice.org/11311
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>