Null checks to make GCC warnings go away

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