Fix null terminator check