fixing a bug where strlen is called with a null pointer