Module: kamailio
Branch: master
Commit: b1a47746d6097c2d1fe47ee4799108368037283d
URL: 
https://github.com/kamailio/kamailio/commit/b1a47746d6097c2d1fe47ee4799108368037283d

Author: Pantelis Kolatsis <p...@gilawa.com>
Committer: Henning Westerholt <h...@gilawa.com>
Date: 2023-04-29T19:16:32Z

pua: convert to memory logging helper, add missing log message and mem error 
handling

---

Modified: src/modules/pua/hash.c
Modified: src/modules/pua/pua.c
Modified: src/modules/pua/send_publish.c
Modified: src/modules/pua/send_subscribe.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/b1a47746d6097c2d1fe47ee4799108368037283d.diff
Patch: 
https://github.com/kamailio/kamailio/commit/b1a47746d6097c2d1fe47ee4799108368037283d.patch

---

diff --git a/src/modules/pua/hash.c b/src/modules/pua/hash.c
index 9b1fec3d0d..8bd4a442e6 100644
--- a/src/modules/pua/hash.c
+++ b/src/modules/pua/hash.c
@@ -229,6 +229,9 @@ void update_htable(ua_pres_t* p, time_t desired_expires, 
int expires,
                        if(p->remote_contact.s== NULL)
                        {
                                SHM_MEM_ERROR;
+                               if(etag) {
+                                       shm_free(p->etag.s);
+                               }
                                return;
                        }
                        memcpy(p->remote_contact.s, contact->s, contact->len);
diff --git a/src/modules/pua/pua.c b/src/modules/pua/pua.c
index 33ddeddba4..255d0fa1bf 100644
--- a/src/modules/pua/pua.c
+++ b/src/modules/pua/pua.c
@@ -601,6 +601,9 @@ static int db_restore(void)
                                if(p->etag.s==  NULL)
                                {
                                        SHM_MEM_ERROR;
+                                       if(watcher_uri.s && watcher_uri.len) {
+                                               shm_free(p->remote_contact.s);
+                                       }
                                        goto error;
                                }
                                memcpy(p->etag.s, etag.s, etag.len);
diff --git a/src/modules/pua/send_publish.c b/src/modules/pua/send_publish.c
index 58e67de82d..c19ff1b965 100644
--- a/src/modules/pua/send_publish.c
+++ b/src/modules/pua/send_publish.c
@@ -409,6 +409,7 @@ void publ_cback_func(struct cell *t, int type, struct 
tmcb_params *ps)
        if(presentity->etag.s== NULL)
        {
                SHM_MEM_ERROR;
+               shm_free(presentity);
                goto error;
        }
        memcpy(presentity->etag.s, etag.s, etag.len);
diff --git a/src/modules/pua/send_subscribe.c b/src/modules/pua/send_subscribe.c
index dc239c61b6..1791e6cca2 100644
--- a/src/modules/pua/send_subscribe.c
+++ b/src/modules/pua/send_subscribe.c
@@ -654,7 +654,9 @@ void subs_cback_func(struct cell *t, int cb_type, struct 
tmcb_params *ps)
        presentity->remote_contact.s= (char*)shm_malloc(contact.len* 
sizeof(char));
        if(presentity->remote_contact.s==NULL)
        {
-               ERR_MEM(SHARE_MEM);
+               SHM_MEM_ERROR;
+               shm_free(presentity);
+               return;
        }
        memcpy(presentity->remote_contact.s, contact.s, contact.len);
        presentity->remote_contact.len= contact.len;

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to