Fix a read off the end of the input buffer