fixed buffer alloc issue