fix PREFAST warnings about possible NULL pointer derefs & non-zero-terminated strings #3590