fix infinite loop parsing an invalid header