Module: sip-router
Branch: 4.0
Commit: 91f64af86eebde4a179a4d9cb6837994a587a967
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=91f64af…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)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
(cherry picked from commit 71d7dc6bc750406d510e0571e05da3966911cfea)
---
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)