Fix null pointer dereferences
Fix null pointer dereferences

As reported by Coverity Scan

MaartenBent/matio,tbeu/matio,MaartenBent/matio,tbeu/matio,tbeu/matio,tbeu/matio,MaartenBent/matio,NJannasch/matio,MaartenBent/matio,NJannasch/matio