Selaa lähdekoodia

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

Pantelis Kolatsis 2 vuotta sitten
vanhempi
commit
b1a47746d6

+ 3 - 0
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);

+ 3 - 0
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);

+ 1 - 0
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);

+ 3 - 1
src/modules/pua/send_subscribe.c

@@ -654,7 +654,9 @@ faked_error:
 	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;