memory leak when serializing SCALARs

Frank Fock Frank.Fock____t-online.de
Wed May 28 21:08:35 CEST 2003


Hi Dave,

 From the source code I do not see where there could be
a leak. Also Purify does not find any, but does not
proof anything either. Do you have an idea what could
be wrong by looking at the source?

boolean MibLeaf::serialize(char*& buf, int& sz)
{
	Vbx vb(get_oid());
	vb.set_value(*value);
	return (Vbx::to_asn1(&vb, 1, (unsigned char*&)buf, sz) ==
		SNMP_CLASS_SUCCESS) ? TRUE : FALSE;
}

boolean MibLeaf::deserialize(char* buf, int& sz)
{
	Vbx* vbs;
	int size = 0;
	unsigned char* data = (unsigned char*)buf;
	int status = Vbx::from_asn1(vbs, size, data, sz);
	if ((status == SNMP_CLASS_SUCCESS) && (size > 0)) {
		init(vbs[0].clone_value(), value_mode);
		delete[] vbs;
		return TRUE;
	}
	return FALSE;
}

void MibLeaf::init(SnmpSyntax* s, int mode)
{
	validity = 0;
	value = s;
	value_mode = mode;
	if (mode & VMODE_DEFAULT)
		validity |= LEAF_VALUE_INITIALIZED;
	my_table = 0;
	my_row   = 0;
	undo	 = 0;
}	


Best regards,
Frank

Dave Barratt wrote:
> Hi,
> I get memory leaks when using the mib persist feature (i.e. I've put a 
> 'config' dir in my working dir), but only with objects that are NOT in a 
> table (SCALARS?). To test this theory I moved some scalars to be in a 
> table & hey presto, no leaks from the objects.  This means that I get 
> memory leaks from the built-in sysGroup & snmpGroup as well.  The leaks 
> are detected by Bounds Checker & VC6.  Has anyone got an idea of whats 
> going wrong in this case?
>  
> Dave Barratt
> Developer
> Codima Technologies - redefining the art of network management
> E-mail:  dbarratt____codimatech.com <mailto:dbarratt____codimatech.com>






More information about the AGENTPP mailing list