Browse code

pua: free in case of errors

Daniel-Constantin Mierla authored on 31/07/2017 13:53:27
Showing 3 changed files
... ...
@@ -150,6 +150,7 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
150 150
 				LM_ERR("No more memory\n");
151 151
 				goto error;
152 152
 			}
153
+			alloc_tuple = 1;
153 154
 			tuple->s= (char*)pkg_malloc(tuple_id_len* sizeof(char));
154 155
 			if(tuple->s== NULL)
155 156
 			{
... ...
@@ -160,7 +161,6 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
160 160
 			tuple->len= tuple_id_len;
161 161
 
162 162
 			*tuple_param= tuple;
163
-			alloc_tuple= 1;
164 163
 
165 164
 			LM_DBG("allocated tuple_id\n\n");
166 165
 		}
... ...
@@ -252,12 +252,10 @@ error:
252 252
 		xmlFreeDoc(doc);
253 253
 	if(body)
254 254
 		pkg_free(body);
255
-	if(tuple && alloc_tuple)
256
-	{
255
+	if(tuple && alloc_tuple) {
257 256
 		if(tuple->s)
258 257
 			pkg_free(tuple->s);
259 258
 		pkg_free(tuple);
260
-		tuple= NULL;
261 259
 	}
262 260
 	return -1;
263 261
 
... ...
@@ -457,7 +457,7 @@ done:
457 457
 	return;
458 458
 
459 459
 error:
460
-	if(*ps->param)
460
+	if(ps->param && *ps->param)
461 461
 	{
462 462
 		shm_free(*ps->param);
463 463
 		*ps->param= NULL;
... ...
@@ -980,6 +980,7 @@ int send_subscribe(subs_info_t* subs)
980 980
 	if(str_hdr== NULL || str_hdr->s== NULL)
981 981
 	{
982 982
 		LM_ERR("while building extra headers\n");
983
+		if(str_hdr) pkg_free(str_hdr);
983 984
 		return -1;
984 985
 	}
985 986