FLEX-34634 - add null check (patch provided by Gareth Daniel Smith)

Signed-off-by: Erik de Bruin <erik@ixsoftware.nl>
Fix whitespace

Signed-off-by: Erik de Bruin <erik@ixsoftware.nl>