Browse code

- fixed mem. leaks in acc_ {db,rad}_missed, sip_resolvehost, receive_msg

Andrei Pelinescu-Onciul authored on 21/08/2003 10:57:23
Showing 4 changed files
... ...
@@ -2,19 +2,22 @@ $Id$
2 2
 
3 3
 ( - todo, x - done)
4 4
 
5
-- backport tcp conn id fix to stable
6 5
 - change len_gt into and expr (e.g msg:len).
7 6
 - sipit: uri == myself doesn't match tls port = 5061
8 7
 - sipit: fix check_self & *_alias to work with tcp & tls
9 8
 - sipit: fix ipv6 references in check_self
10 9
 - regex subst on uris?
11
-- port receive.c pre_script_cb fix from stable
10
+x port receive.c pre_script_cb fix from stable
12 11
 - extend alias to include port numbers :
13 12
     something like alias= foo1.bar:5080 foo2.bar foo3.bar:*
14 13
 - extend listen and alias to include port numbers and protocol:
15 14
        tcp foo.bar:5063, udp foo.bar:5062, foo2.bar
16 15
 
17 16
 release:
17
+- backport: tcp conn id fix to stable + destroy_tcp 
18
+- backport: acc mem. leak fixes
19
+- backport: dns mem. leak fixes (resolve.[ch])
20
+- backport: id_builder receive_msg mem. leak (receive.c)
18 21
 - change tcp timeouts to 2 or 3 min?
19 22
 x check via ipv6 fixes and backport to stable
20 23
 x fix kill(0, SIGTERM) on startup error (will kill also the launching shell
... ...
@@ -1186,7 +1186,8 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
1186 1186
 		if  ((id_buf=id_builder(msg, &id_len))==0){
1187 1187
 			LOG(L_ERR, "ERROR: build_req_buf_from_sip_req:"
1188 1188
 							" id_builder failed\n");
1189
-			goto error01; /* free everything */
1189
+			goto error00; /* we don't need to free anything,
1190
+			                 nothing alloc'ed yet*/
1190 1191
 		}
1191 1192
 		DBG("build_req_from_req: id added: <%.*s>, rcv proto=%d\n",
1192 1193
 				(int)id_len, id_buf, msg->rcv.proto);
... ...
@@ -1315,7 +1316,7 @@ skip_clen:
1315 1315
 		 * parse_headers is called from clen_builder */
1316 1316
 		anchor=anchor_lump(&(msg->add_rm), msg->unparsed-buf, 0,
1317 1317
 							 HDR_CONTENTLENGTH);
1318
-		if (anchor==0) goto error04; /* free clen_buf*/
1318
+		if (anchor==0) goto error04; /* free clen_buf */
1319 1319
 		if (insert_new_lump_after(anchor, clen_buf, clen_len,
1320 1320
 					HDR_CONTENTLENGTH)==0)
1321 1321
 			goto error04; /* free clen_buf*/
... ...
@@ -1366,13 +1367,15 @@ skip_clen:
1366 1366
 #endif
1367 1367
 
1368 1368
 	*returned_len=new_len;
1369
+	/* cleanup */
1370
+#ifdef USE_TCP
1371
+	if (id_buf) pkg_free(id_buf); /* it's not in a lump => we don't need it
1372
+									 anymore */
1373
+#endif
1369 1374
 	return new_buf;
1370 1375
 
1371 1376
 error01:
1372
-	pkg_free(line_buf);
1373
-#ifdef USE_TCP
1374
-	if (id_buf) pkg_free(id_buf);
1375
-#endif
1377
+	if (line_buf) pkg_free(line_buf);
1376 1378
 error02:
1377 1379
 	if (received_buf) pkg_free(received_buf);
1378 1380
 error03:
... ...
@@ -1382,6 +1385,9 @@ error04:
1382 1382
 	if (clen_buf) pkg_free(clen_buf);
1383 1383
 #endif
1384 1384
 error00:
1385
+#ifdef USE_TCP
1386
+	if (id_buf) pkg_free(id_buf);
1387
+#endif
1385 1388
 	*returned_len=0;
1386 1389
 	return 0;
1387 1390
 }
... ...
@@ -529,6 +529,7 @@ struct hostent* sip_resolvehost(str* name, unsigned short* port, int proto)
529 529
 					return he;
530 530
 				}
531 531
 			}
532
+			if (head) free_rdata_list(head); /*clean up*/
532 533
 			DBG("sip_resolvehost: not SRV record found for %.*s," 
533 534
 					" trying 'normal' lookup...\n", name->len, name->s);
534 535
 		}
... ...
@@ -1006,6 +1006,11 @@ void destroy_tcp()
1006 1006
 		shm_free(tcpconn_id_hash);
1007 1007
 		tcpconn_id_hash=0;
1008 1008
 	}
1009
+	
1010
+	if(connection_id){
1011
+		shm_free(connection_id);
1012
+		connection_id=0;
1013
+	}
1009 1014
 }
1010 1015
 
1011 1016