added several NULL-pointer checks
added several NULL-pointer checks

fixes segfaults that occurs under certain circumstances

ThomasAdam/vimprobable,ThomasAdam/vimprobable,desyncr/vimprobable,DeadDork/vimprobable2,desyncr/vimprobable,hut/vimprobable,hut/vimprobable,fanglingsu/vimprobable,hut/vimprobable,DeadDork/vimprobable2,desyncr/vimprobable,desyncr/vimprobable,fanglingsu/vimprobable,DeadDork/vimprobable2,ThomasAdam/vimprobable,fanglingsu/vimprobable,DeadDork/vimprobable2