You are viewing a plain text version of this content. The canonical link for it is here.
Posted to websh-cvs@tcl.apache.org by ro...@apache.org on 2006/03/05 19:37:28 UTC

svn commit: r383364 - /tcl/websh/trunk/src/generic/log.c

Author: ronnie
Date: Sun Mar  5 10:37:27 2006
New Revision: 383364

URL: http://svn.apache.org/viewcvs?rev=383364&view=rev
Log:
- fixed memory leak when initializing logData->listOfFilters
  and logData->listOfDests

Modified:
    tcl/websh/trunk/src/generic/log.c

Modified: tcl/websh/trunk/src/generic/log.c
URL: http://svn.apache.org/viewcvs/tcl/websh/trunk/src/generic/log.c?rev=383364&r1=383363&r2=383364&view=diff
==============================================================================
--- tcl/websh/trunk/src/generic/log.c (original)
+++ tcl/websh/trunk/src/generic/log.c Sun Mar  5 10:37:27 2006
@@ -81,7 +81,7 @@
     WebAssertData(interp, logtochannel, "log_Init/logtochannel plugin",
 		  TCL_ERROR)
 
-	logtochannel->constructor = createLogToChannel;
+    logtochannel->constructor = createLogToChannel;
     logtochannel->destructor = destroyLogToChannel;
     logtochannel->handler = logToChannel;
 
@@ -118,7 +118,7 @@
     logtosyslog = createLogPlugIn();
     WebAssertData(interp, logtocmd, "log_Init/logtosyslog plugin", TCL_ERROR)
 
-	logtosyslog->constructor = createLogToSyslog;
+    logtosyslog->constructor = createLogToSyslog;
     logtosyslog->destructor = destroyLogToSyslog;
     logtosyslog->handler = logToSyslog;
 
@@ -147,6 +147,7 @@
 	logData->filterSize = 0;
 	logData->listOfDests = NULL;
 	logData->destSize = 0;
+	/* fake calls to initialize filters and destinations */
 	insertIntoFilterList(logData, (LogLevel *) NULL);
 	insertIntoDestList(logData, (LogDest *) NULL);
 
@@ -318,7 +319,12 @@
     logData->listOfDests = newLogDests;
     logData->destSize += LOG_LIST_INITIAL_SIZE;
     WebFreeIfNotNull(logDests);
-    return insertIntoDestList(logData, logDest);
+    if (logDest != NULL) {
+      /* only when not fake call to inizialize listOfDests*/
+      return insertIntoDestList(logData, logDest);
+    } else {
+      return NULL;
+    }
   }
 }
 
@@ -347,7 +353,12 @@
     logData->listOfFilters = newLogLevels;
     logData->filterSize += LOG_LIST_INITIAL_SIZE;
     WebFreeIfNotNull(logLevels);
-    return insertIntoFilterList(logData, logLevel);
+    if (logLevel != NULL) {
+      /* only when not fake call to inizialize listOfDests*/
+      return insertIntoFilterList(logData, logLevel);
+    } else {
+      return NULL;
+    }
   }
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: websh-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-cvs-help@tcl.apache.org