Fix memory leak when realloc fails
Created by: Chocobo1
Found by cppcheck. There are some warnings leftover, but it seems to be small that I don't bother touch it.
Created by: Chocobo1
Found by cppcheck. There are some warnings leftover, but it seems to be small that I don't bother touch it.