fix possible null deref (detected by code coverity scan)