Fix memory leak and buffer size in TempString