<p>Calling remove_hf() more than once for the same header causes the resulting sip message to be malformed.</p>

<p>In my case I am calling remove_hf() on replies to remove custom headers.</p>

<p>Hopefully this pastes OK, ngrep output from calling remove_hf("^X-", "r") twice on the same 200 response:</p>

<p>U 2014/05/02 10:12:43.357835 192.168.122.77:5060 -&gt; 192.168.122.192:5060<br>
  SIP/2.0 200 OK..Record-Route: <a>sip:192.168.122.192;lr;did=108.c0119662</a>..Via: SIP/2.0/UDP 192.168.122.192:5060;branch=z9hG4bKe7c.52cb9726.0..Via: SIP/2.0/UDP 192.168.122.1:5060;received=192.168.122.1;branch=z9hG4bK.0CPmTlXzE;rport=5<br>
  060..From: <a>sip:test@192.168.122.192</a>;tag=wm0dKOJVk..To: sip:55555@192.168.122.192;tag=PRSHP.25474.4577..CSeq: 20 INVITE..Call-ID: B-WyTTdMsk..Content-Type: application/sdp..Supported: timer..Allow: INVITE, ACK, CANCEL, OPTIONS, BYE<br>
  , REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH..X-TEST: Test Header..Contact: <a>sip:192.168.122.77:5060</a>..Server: Pirate Proxy..Content-Length: 239....v=0..o=root 982256734 982256734 IN IP4 192.168.122.218..s=Asterisk PBX 11.7.0..c=IN IP4<br>
   192.168.122.218..t=0 0..m=audio 17666 RTP/AVP 0 101..a=rtpmap:0 PCMU/8000..a=rtpmap:101 telephone-event/8000..a=fmtp:101 0-16..a=ptime:20..a=sendrecv..                                                                                </p>

<p>U 2014/05/02 10:12:43.366696 192.168.122.192:5060 -&gt; 192.168.122.1:5060<br>
  SIP/2.0 200 OK..Record-Route: <a>sip:192.168.122.192;lr;did=108.c0119662</a>..Via: SIP/2.0/UDP 192.168.122.1:5060;received=192.168.122.1;branch=z9hG4bK.0CPmTlXzE;rport=5060..From: <a>sip:test@192.168.122.192</a>;tag=wm0dKOJVk..To: sip:55555@1<br>
  92.168.122.192;tag=PRSHP.25474.4577..CSeq: 20 INVITE..Call-ID: B-WyTTdMsk..Content-Type: application/sdp..Supported: timer..Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH...122.77:5060&gt;..Server: Pi<br>
  rate Proxy..Content-Length: 257....v=0..o=root 982256734 982256734 IN IP4 192.168.122.192..s=Asterisk PBX 11.7.0..c=IN IP4 192.168.122.192..t=0 0..m=audio 63074 RTP/AVP 0 101..a=rtpmap:0 PCMU/8000..a=rtpmap:101 telephone-event/8000.<br>
  .a=fmtp:101 0-16..a=ptime:20..a=sendrecv..a=nortpproxy:yes..</p>

<p>Notice how a portion of the contact header gets removed and '122.77:5060&gt;' is left behind.</p>

<p>Opensips information:<br>
version: opensips 1.10.1-notls (x86_64/linux)<br>
flags: STATS: On, DISABLE_NAGLE, SHM_MEM, SHM_MMAP, PKG_MALLOC, F_MALLOC, FAST_LOCK-FUTEX-ADAPTIVE_WAIT<br>
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535<br>
git revision: <a href="https://github.com/OpenSIPS/opensips/commit/05f97a3" class="commit-link"><tt>05f97a3</tt></a><br>
@(#) $Id$<br>
main.c compiled on 10:47:11 Apr 30 2014 with gcc 4.7.2</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href='https://github.com/OpenSIPS/opensips/issues/219'>view it on GitHub</a>.<img src='https://github.com/notifications/beacon/5479561__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcxNDY3MDQ4MywiZGF0YSI6eyJpZCI6MzEzMzE5ODB9fQ==--147af88e4d75b3884eeb3c43ce0e3a602b894b6e.gif' height='1' width='1'></p>