Fix potential segfaults
Fix potential segfaults

svn path=/trunk/dom/; revision=3544

prepare/netsurf_libdom,dunkelstern/libdom,prepare/netsurf_libdom,Achal-Aggarwal/libdom,Achal-Aggarwal/libdom,dunkelstern/libdom,Achal-Aggarwal/libdom,prepare/netsurf_libdom,dunkelstern/libdom,prepare/netsurf_libdom,dunkelstern/libdom,Achal-Aggarwal/libdom,Achal-Aggarwal/libdom,Achal-Aggarwal/libdom,prepare/netsurf_libdom,dunkelstern/libdom,dunkelstern/libdom,prepare/netsurf_libdom