Browse code

- fixed pkg_free/malloc bug for new_uri (action.c/do_action/SET_*)

Andrei Pelinescu-Onciul authored on 04/12/2001 00:41:35
Showing 2 changed files
... ...
@@ -15,6 +15,7 @@
15 15
 #include "msg_parser.h"
16 16
 #include "ut.h"
17 17
 #include "sr_module.h"
18
+#include "mem.h"
18 19
 
19 20
 #include <sys/types.h>
20 21
 #include <sys/socket.h>
... ...
@@ -212,11 +213,11 @@ int do_action(struct action* a, struct sip_msg* msg)
212 213
 				}
213 214
 				if (a->type==SET_URI_T){
214 215
 					if (msg->new_uri.s) {
215
-							free(msg->new_uri.s);
216
+							pkg_free(msg->new_uri.s);
216 217
 							msg->new_uri.len=0;
217 218
 					}
218 219
 					len=strlen(a->p1.string);
219
-					msg->new_uri.s=malloc(len+1);
220
+					msg->new_uri.s=pkg_malloc(len+1);
220 221
 					if (msg->new_uri.s==0){
221 222
 						LOG(L_ERR, "ERROR: do_action: memory allocation"
222 223
 								" failure\n");
... ...
@@ -244,7 +245,7 @@ int do_action(struct action* a, struct sip_msg* msg)
244 245
 					break;
245 246
 				}
246 247
 				
247
-				new_uri=malloc(MAX_URI_SIZE);
248
+				new_uri=pkg_malloc(MAX_URI_SIZE);
248 249
 				if (new_uri==0){
249 250
 					LOG(L_ERR, "ERROR: do_action: memory allocation "
250 251
 								" failure\n");
... ...
@@ -317,7 +318,7 @@ int do_action(struct action* a, struct sip_msg* msg)
317 318
 				}
318 319
 				*crt=0; /* null terminate the thing */
319 320
 				/* copy it to the msg */
320
-				if (msg->new_uri.s) free(msg->new_uri.s);
321
+				if (msg->new_uri.s) pkg_free(msg->new_uri.s);
321 322
 				msg->new_uri.s=new_uri;
322 323
 				msg->new_uri.len=crt-new_uri;
323 324
 				free_uri(&uri);
... ...
@@ -444,7 +444,8 @@ int parse_uri(char *buf, int len, struct sip_uri* uri)
444 444
 	headers=q_memchr(host,'?',end-host);
445 445
 	params=q_memchr(host,';',end-host);
446 446
 	port=q_memchr(host,':',end-host);
447
-	host_len=(port)?port-host:(params)?params-host:(headers)?headers-host:end-host;
447
+	host_len=(port)?port-host:(params)?params-host:(headers)?headers-host:
448
+		end-host;
448 449
 	/* get host */
449 450
 	uri->host.s=pkg_malloc(host_len+1);
450 451
 	if (uri->host.s==0){