[Asterisk-cvs] asterisk/cdr cdr_odbc.c,1.6,1.7

jeremy at lists.digium.com jeremy at lists.digium.com
Tue Dec 23 21:13:28 CST 2003


Update of /usr/cvsroot/asterisk/cdr
In directory mongoose.digium.com:/tmp/cvs-serv5937

Modified Files:
	cdr_odbc.c 
Log Message:
fix a small memory leak, from brian


Index: cdr_odbc.c
===================================================================
RCS file: /usr/cvsroot/asterisk/cdr/cdr_odbc.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cdr_odbc.c	24 Dec 2003 00:04:33 -0000	1.6
+++ cdr_odbc.c	24 Dec 2003 03:05:03 -0000	1.7
@@ -38,7 +38,7 @@
 static char *name = "ODBC";
 static char *config = "cdr_odbc.conf";
 static char *dsn = NULL, *username = NULL, *password = NULL, *loguniqueid = NULL;
-static int dsn_alloc = 0, username_alloc = 0, password_alloc = 0;
+static int dsn_alloc = 0, username_alloc = 0, password_alloc = 0, loguniqueid_alloc = 0;
 static int connected = 0;
 
 static ast_mutex_t odbc_lock = AST_MUTEX_INITIALIZER;
@@ -226,6 +226,14 @@
 		password = NULL;
 		password_alloc = 0;
 	}
+	if (loguniqueid && loguniqueid_alloc)
+	{
+		if(option_verbose > 3)
+			ast_verbose( VERBOSE_PREFIX_4 "cdr_odbc: free loguniqueid\n");
+		free(loguniqueid);
+		loguniqueid = NULL;
+		loguniqueid_alloc = 0;
+	}
 	ast_cdr_unregister(name);
 	ast_mutex_unlock(&odbc_lock);
 	return 0;
@@ -323,11 +331,13 @@
 		if (loguniqueid != NULL)
 		{
 			strcpy(loguniqueid,tmp);
+			loguniqueid_alloc = 1;
 			ast_log(LOG_WARNING,"cdr_odbc: Logging uniqueid\n");
 		}
 		else
 		{
 			ast_log(LOG_ERROR,"cdr_odbc: Not logging uniqueid\n");
+			loguniqueid_alloc = 1;
 			loguniqueid = NULL;
 		}
 	}




More information about the svn-commits mailing list