fix input buffer infinite loop