fix segfault of reading string from NULL