[159] in Hesiod

home help back first fref pref prev next nref lref last post

Major memory leak in hes_resolv

daemon@ATHENA.MIT.EDU (Mike Busby)
Fri Oct 8 17:42:05 1993

From: mcb@mach.eng.hou.compaq.com (Mike Busby)
To: hesiod@MIT.EDU
Date: Fri, 8 Oct 93 16:38:44 CDT
Cc: kutcher@mach.eng.hou.compaq.com (Jeffrey Kutcher)


In the process of debugging a problem, Jeff found a memory leak in
hes_resolv.  If succesive calls are made to this function, memory
is not de-allocated.  He found this by running the Purify program
on a program that iterated with hes_resolv in the loop.

Here is what he changed to remove the memory leak:

char **
hes_resolve(HesiodName, HesiodNameType)
char *HesiodName, *HesiodNameType;
{
	register char *cp;
	register char **p;
	static char *retvec[100];
        static char **savep = (char **)NULL;
	char *ocp, *dst;
	char *calloc();
	int i, j, n;
	struct nsmsg *ns, *_resolve();
	rr_t *rp;
	extern int errno;

/*
The following frees previously allocated store allocated from a
previous call to hes_resolve(). - Jeff Kutcher (8-Oct-1993)
*/
/* BEGIN FIX: */
        if(savep)
                for(p=savep;*p;p++)
                        free(*p);

	savep = retvec;
/* END FIX */

	cp = hes_to_bind(HesiodName, HesiodNameType);
	if (cp == NULL) return(NULL);

My question is: Has this problem been solved in subsequent releases?  We
are using what is currently available on aeneas.mit.edu.  I would be
suprised if someone else has not seen this problem.  It is definately
causing problems in our applications.

-- 
------------------------------------------------------------------
Michael C. Busby                |  Unix System Support
System Engineer, Sr.            |  Design Environment/Automation
Compaq Computer Corporation     |  Internet: mcb@compaq.com        
P.O. Box 692000 m/s 050701      |  Uunet:    uunet!cpqhou!michaelb 
Houston, Texas, USA 77269-2000  |  Phone:    713-374-5638          
------------------------------------------------------------------
"Armadillos....  Texas speed bumps."    Views/opinions are mine alone.

home help back first fref pref prev next nref lref last post