Module: sip-router
Branch: master
Commit: 71d7dc6bc750406d510e0571e05da3966911cfea
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=71d7dc6bc750406d510e0571e05da3966911cfea

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date:   Mon Jul  1 14:51:03 2013 +0200

dialog: avoid realloc of memory for cseq when setting leg info

- free already allocated structs when needed
- has part of a patch by Halina Nowak

---

 modules/dialog/dlg_hash.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/modules/dialog/dlg_hash.c b/modules/dialog/dlg_hash.c
index c669290..bba619a 100644
--- a/modules/dialog/dlg_hash.c
+++ b/modules/dialog/dlg_hash.c
@@ -485,8 +485,19 @@ int dlg_set_leg_info(struct dlg_cell *dlg, str* tag, str 
*rr, str *contact,
 {
        char *p;
 
+       if(dlg->tag[leg].s)
+               shm_free(dlg->tag[leg].s);
        dlg->tag[leg].s = (char*)shm_malloc( tag->len + rr->len + contact->len 
);
-       dlg->cseq[leg].s = (char*)shm_malloc( cseq->len );
+
+       if(dlg->cseq[leg].s) {
+               if (dlg->cseq[leg].len < cseq->len) {
+                       shm_free(dlg->cseq[leg].s);
+                       dlg->cseq[leg].s = (char*)shm_malloc(cseq->len);
+               }
+       } else {
+               dlg->cseq[leg].s = (char*)shm_malloc( cseq->len );
+       }
+
        if ( dlg->tag[leg].s==NULL || dlg->cseq[leg].s==NULL) {
                LM_ERR("no more shm mem\n");
                if (dlg->tag[leg].s)


_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to