ntreg: crash fixes by performing more error checking