- fixed memory leak when rewritting uri
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Wed, 26 Sep 2001 17:18:01 +0000 (17:18 +0000)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Wed, 26 Sep 2001 17:18:01 +0000 (17:18 +0000)
- route match after new uri
- dmalloc debuging support

12 files changed:
Makefile
action.c
cfg.lex
cfg.y
forward.c
main.c
msg_parser.c
proxy.c
receive.c
route.c
route_struct.c
udp_server.c

index 54c5595..6186daa 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,13 +16,13 @@ NAME=sip_router
 
 
 CC=gcc
-CFLAGS=-O2 -Wcast-align  #-Wmissing-prototypes  -Wall
+CFLAGS=-O2 -Wcast-align #-Wmissing-prototypes  -Wall
 LEX=lex
 YACC=yacc
 YACC_FLAGS=-d -b cfg
 # on linux and freebsd keep it empty (e.g. LIBS= )
 # on solaris add -lxnet (e.g. LIBS= -lxnet)
-LIBS=-lfl -L/usr/local/lib
+LIBS=-lfl -L/usr/local/lib 
 ALLDEP=Makefile
 
 MKDEP=gcc -M
index c56039b..a1130fe 100644 (file)
--- a/action.c
+++ b/action.c
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
+#ifdef DEBUG_DMALLOC
+#include <dmalloc.h>
+#endif
+
 
 /* ret= 0! if action -> end of list(e.g DROP), 
       > 0 to continue processing next actions
diff --git a/cfg.lex b/cfg.lex
index 49f395f..e5d8e20 100644 (file)
--- a/cfg.lex
+++ b/cfg.lex
@@ -9,6 +9,11 @@
        #include "cfg.tab.h"
        #include "dprint.h"
        #include <string.h>
+       #include <stdlib.h>
+
+#ifdef DEBUG_DMALLOC
+#include <dmalloc.h>
+#endif
 
        /* states */
        #define INITIAL_S               0
diff --git a/cfg.y b/cfg.y
index dfb76d5..71ac44c 100644 (file)
--- a/cfg.y
+++ b/cfg.y
 #include "route.h"
 #include "dprint.h"
 
+#ifdef DEBUG_DMALLOC
+#include <dmalloc.h>
+#endif
+
 void yyerror(char* s);
 char* tmp;
 
index 13a3119..7f14618 100644 (file)
--- a/forward.c
+++ b/forward.c
 #include "udp_server.h"
 #include "globals.h"
 
+#ifdef DEBUG_DMALLOC
+#include <dmalloc.h>
+#endif
+
 #define MAX_VIA_LINE_SIZE      240
 #define MAX_RECEIVED_SIZE  57
 
diff --git a/main.c b/main.c
index c524e67..d22c2da 100644 (file)
--- a/main.c
+++ b/main.c
 #include "globals.h"
 
 
+#ifdef DEBUG_DMALLOC
+#include <dmalloc.h>
+#endif
+
+
 static char id[]="@(#) $Id$";
 static char version[]="sip_router 0.6";
 static char help_msg[]= "\
index c489c36..77c6e99 100644 (file)
 #include "error.h"
 #include "dprint.h"
 
+#ifdef DEBUG_DMALLOC
+#include <dmalloc.h>
+#endif
+
 
 
 #define DEBUG
diff --git a/proxy.c b/proxy.c
index ca6d392..614f53d 100644 (file)
--- a/proxy.c
+++ b/proxy.c
@@ -13,6 +13,9 @@
 #include <string.h>
 #include <stdlib.h>
 
+#ifdef DEBUG_DMALLOC
+#include <dmalloc.h>
+#endif
 
 struct proxy_l* proxies=0;
 
index f4139b6..7ac1f83 100644 (file)
--- a/receive.c
+++ b/receive.c
@@ -12,6 +12,9 @@
 #include "forward.h"
 #include "action.h"
 
+#ifdef DEBUG_DMALLOC
+#include <dmalloc.h>
+#endif
 
 int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
 {
@@ -78,9 +81,11 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
                }
        }
 skip:
+       if (msg.new_uri) free(msg.new_uri);
        free(msg.orig);
        return 0;
 error:
+       if (msg.new_uri) free(msg.new_uri);
        free(msg.orig);
 error1:
        return -1;
diff --git a/route.c b/route.c
index b54f30a..5058929 100644 (file)
--- a/route.c
+++ b/route.c
 #include "dprint.h"
 #include "proxy.h"
 
+#ifdef DEBUG_DMALLOC
+#include <dmalloc.h>
+#endif
+
 /* main routing list */
 struct route_elem* rlist[RT_NO];
 
@@ -284,8 +288,13 @@ static int eval_elem(struct expr* e, struct sip_msg* msg)
                                                                e->op, e->subtype);
                                break;
                case URI_O:
-                               ret=comp_str(msg->first_line.u.request.uri, e->r.param,
-                                                               e->op, e->subtype);
+                               if(msg->new_uri){
+                                       ret=comp_str(msg->new_uri, e->r.param,
+                                                                       e->op, e->subtype);
+                               }else{
+                                       ret=comp_str(msg->first_line.u.request.uri, e->r.param,
+                                                                       e->op, e->subtype);
+                               }
                                break;
                case SRCIP_O:
                                ret=comp_ip(msg->src_ip, e->r.param, e->op, e->subtype);
index 92efea7..738b768 100644 (file)
 
 #include "dprint.h"
 
+#ifdef DEBUG_DMALLOC
+#include <dmalloc.h>
+#endif
+
 struct expr* mk_exp(int op, struct expr* left, struct expr* right)
 {
        struct expr * e;
index 7839521..5a410cf 100644 (file)
@@ -15,6 +15,9 @@
 #include "dprint.h"
 #include "receive.h"
 
+#ifdef DEBUG_DMALLOC
+#include <dmalloc.h>
+#endif
 
 int udp_sock;