2c663643dd
1) restore the scanner's original cursor position in case of insufficient input; 2) free the memories allocated for a new header in case of a failure. (cherry picked from commit 7a571f513e801f071873f2627400461b04213b13)