Fix potential bug when pasting large buffers