[comp.bugs.misc] Minor bug in Pathalias

matt@ncr-sd.SanDiego.NCR.COM (Matt Costello) (07/02/87)

There is a minor bug in the pathalias(1) program.
The bug causes pathalias to dump core when it runs out of
memory.  It is in the routine mymalloc() in the file mem.c;
its sccsid is
	mem.c	8.3 (down!honey) 86/06/08

The problem is that the mymalloc() routine does not check the
malloc(3) return value before trying to clear the memory returned
by malloc.  The published maps are getting big enough that a
process size of 1 MB is no longer big enough to run pathalias.

This bug is present in both the January 1986 and November 1986
distributions.  The following is a context diff of the change
for the November 1986 distribution:

*** mem.c.orig	Fri Feb  6 20:54:24 1987
--- mem.c	Wed Jul  1 13:24:38 1987
***************
*** 199,205
  
  	if (n >= 1024) {		/* for hash table */
  		rval = malloc(n);	/* aligned */
! 		strclear(rval, n);
  		return(rval);
  	}
  

--- 199,206 -----
  
  	if (n >= 1024) {		/* for hash table */
  		rval = malloc(n);	/* aligned */
! 		if (rval != 0)
! 			strclear(rval, n);
  		return(rval);
  	}
  
-- 
Matt Costello	<matt.costello@SanDiego.NCR.COM>
+1 619 485 2926	<matt.costello%SanDiego.NCR.COM@Relay.CS.NET>
		{sdcsvax,cbosgd,pyramid,nosc.ARPA,ihnp4}!ncr-sd!matt