Fix bug allocate memory for string