Re: [tkined] memory leaks in CVS tree

From: Juergen Schoenwaelder (schoenw@ibr.cs.tu-bs.de)
Date: Mon Jun 25 2001 - 09:52:03 MET DST


>>>>> Pete Flugstad writes:

Pete> Yup. Very basic. With the speed of the leak, it's got to be
Pete> something fundamental with packet handling somehwere.

Below is a patch which fixed a memory leak in the code which converts
enumerated names to the underlying numbers. The patch should also be
in the anon CVS archive right now.

/js

Index: tnmMibUtil.c
===================================================================
RCS file: /usr/home/schoenw/CVS/scotty/tnm/snmp/tnmMibUtil.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- tnmMibUtil.c 2001/02/05 15:13:53 1.22
+++ tnmMibUtil.c 2001/06/25 07:47:25 1.23
@@ -10,7 +10,7 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
- * @(#) $Id: tnmMibUtil.c,v 1.22 2001/02/05 15:13:53 schoenw Exp $
+ * @(#) $Id: tnmMibUtil.c,v 1.23 2001/06/25 07:47:25 schoenw Exp $
  */
 
 #include "tnmSnmp.h"
@@ -1138,6 +1138,7 @@
 {
     TnmMibNode *nodePtr = TnmMibFindNode(name, NULL, exact);
     static Tcl_Obj *objPtr = NULL;
+ Tcl_Obj *newObjPtr;
 
     if (!objPtr) {
         objPtr = Tcl_NewStringObj(value, -1);
@@ -1145,10 +1146,12 @@
     
     if (nodePtr) {
         Tcl_SetStringObj(objPtr, value, -1);
- objPtr = TnmMibScanValue(nodePtr->typePtr,
- (int) nodePtr->syntax, objPtr);
- if (objPtr) {
- return Tcl_GetStringFromObj(objPtr, NULL);
+ newObjPtr = TnmMibScanValue(nodePtr->typePtr,
+ (int) nodePtr->syntax, objPtr);
+ if (newObjPtr) {
+ Tcl_SetStringObj(objPtr, Tcl_GetString(newObjPtr), -1);
+ Tcl_DecrRefCount(newObjPtr);
+ return Tcl_GetString(objPtr);
         }
     }
 

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.



This archive was generated by hypermail 2b29 : Thu Jan 03 2002 - 14:56:27 MET