Check for NULL character before calling strchr.