From ec6644c146fe5ca7a1c607de836c7e7043885ad5 Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Fri, 30 Apr 2004 04:05:22 +0000 Subject: [PATCH] Only clear route if we have a new one git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2832 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index ad9c53a4f2..0f07b29c13 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -3699,12 +3699,9 @@ static void build_route(struct sip_pvt *p, struct sip_request *req, int backward struct sip_route *thishop, *head, *tail; int start = 0; int len; + int firstpass = 1; char *rr, *contact, *c; - if (p->route) { - free_old_route(p->route); - p->route = NULL; - } /* We build up head, then assign it to p->route when we're done */ head = NULL; tail = head; /* 1st we pass through all the hops in any Record-Route headers */ @@ -3712,6 +3709,13 @@ static void build_route(struct sip_pvt *p, struct sip_request *req, int backward /* Each Record-Route header */ rr = __get_header(req, "Record-Route", &start); if (*rr == '\0') break; + if (firstpass) { + if (p->route) { + free_old_route(p->route); + p->route = NULL; + } + firstpass = 0; + } for (;;) { /* Each route entry */ /* Find < */