fix buffer memory error