fixed bug with accessing string buffer that was already free()'ed