[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: FW: Memory Leak in ldap_int_initialize(void)



Dear Kurt.

I think that my fixed code is no problem. because "localhost" memory will be alloced in global area.
Often we have a below example code.

------------ below -------------------------------------------------

char* szGlobal = "GlobalData";

void main(void)
{
	...
	// We use szGlobal variable in here.
	...
}
-----------------------------------------------------------------------

but I(or We) don't need free szGlobal. because maybe OS will dealloc the memory.

How think about it?

ps> I'm sorry my english is very poor. so I can't give my all thinking.

	>-----Original Message-----
	>From: Kurt D. Zeilenga [mailto:Kurt@OpenLDAP.org]
	>Sent: Thursday, February 03, 2000 5:33 AM
	>To: Kim, SuYoung
	>Cc: openldap-devel@OpenLDAP.org
	>Subject: Re: FW: Memory Leak in ldap_int_initialize(void)
	>
	>
	>At 02:39 AM 2/3/00 +0900, Kim, SuYoung wrote:
	>>> I am a Korean, so speak a little English. My system is 
	>Windows NT 4.0
	>>> with SP5, Visual C++ 6.0 with SP3.
	>>> I compile a simple ldap program. and I have a memory 
	>leak. so I find
	>>> it! and change the code. it is very simple.
	>>> Just gopts.ldo_defhost = STRDUP("localhost"); => 
	>gopts.ldo_defhost =
	>>> "localhost";
	>
	>Your fix is not valid.  Any attempt to set the global default
	>host would result in free being called with a pointer to a
	>string literal.
	>
	>The appropriate solution is to implement an atexit() handler
	>to do whatever cleanup is needed upon exit().
	>
	>Feel free to implement and submit a proper solution.
	>
	>	Kurt
	>