Kaynağa Gözat

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

Andrei Pelinescu-Onciul 24 yıl önce
ebeveyn
işleme
b78959d0a3
2 değiştirilmiş dosya ile 7 ekleme ve 5 silme
  1. 5 4
      action.c
  2. 2 1
      msg_parser.c

+ 5 - 4
action.c

@@ -15,6 +15,7 @@
 #include "msg_parser.h"
 #include "ut.h"
 #include "sr_module.h"
+#include "mem.h"
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -212,11 +213,11 @@ int do_action(struct action* a, struct sip_msg* msg)
 				}
 				if (a->type==SET_URI_T){
 					if (msg->new_uri.s) {
-							free(msg->new_uri.s);
+							pkg_free(msg->new_uri.s);
 							msg->new_uri.len=0;
 					}
 					len=strlen(a->p1.string);
-					msg->new_uri.s=malloc(len+1);
+					msg->new_uri.s=pkg_malloc(len+1);
 					if (msg->new_uri.s==0){
 						LOG(L_ERR, "ERROR: do_action: memory allocation"
 								" failure\n");
@@ -244,7 +245,7 @@ int do_action(struct action* a, struct sip_msg* msg)
 					break;
 				}
 				
-				new_uri=malloc(MAX_URI_SIZE);
+				new_uri=pkg_malloc(MAX_URI_SIZE);
 				if (new_uri==0){
 					LOG(L_ERR, "ERROR: do_action: memory allocation "
 								" failure\n");
@@ -317,7 +318,7 @@ int do_action(struct action* a, struct sip_msg* msg)
 				}
 				*crt=0; /* null terminate the thing */
 				/* copy it to the msg */
-				if (msg->new_uri.s) free(msg->new_uri.s);
+				if (msg->new_uri.s) pkg_free(msg->new_uri.s);
 				msg->new_uri.s=new_uri;
 				msg->new_uri.len=crt-new_uri;
 				free_uri(&uri);

+ 2 - 1
msg_parser.c

@@ -444,7 +444,8 @@ int parse_uri(char *buf, int len, struct sip_uri* uri)
 	headers=q_memchr(host,'?',end-host);
 	params=q_memchr(host,';',end-host);
 	port=q_memchr(host,':',end-host);
-	host_len=(port)?port-host:(params)?params-host:(headers)?headers-host:end-host;
+	host_len=(port)?port-host:(params)?params-host:(headers)?headers-host:
+		end-host;
 	/* get host */
 	uri->host.s=pkg_malloc(host_len+1);
 	if (uri->host.s==0){