don't use same buffer for input and output, as that leads to race