delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/06/12/13:49:26

Date: Mon, 12 Jun 1995 12:57:17 -0400
From: kagel AT quasar DOT bloomberg DOT com
To: ECE AT dwaf-hri DOT pwv DOT gov DOT za
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Malloc without malice 2
Reply-To: kagel AT ts1 DOT bloomberg DOT com

   From: John Carter <ECE AT dwaf-hri DOT pwv DOT gov DOT za>
   Organization: Dpt Water Affairs & Forestry (IWQS)
   Date: Mon, 12 Jun 1995 15:06:26 +0200

   Maybe I should also mention that the program has successfully done 
   about 1000 malloc()'s and about 500 free()'s before it crashes.

The most common causes for the failure of malloc() are:
	1) Using a pointer after freeing it.
	2) Free()ing the same pointer more than once.
	3) Overwriting beyond an allocated block (watch out for strncpy'd
	  strings as they may not have a NULL terminator! REALLY common prob.)
	4) Free()ing something that was never malloc()ed.

I have a sort program I ported to DJGPP which malloc() and free()s all over the
place and it has never failed.  I have sorted files of several hundred thousand
records which translates to over 1/2 million malloc()s and matching free()s.

Check your code.

-- 
Art S. Kagel, kagel AT ts1 DOT bloomberg DOT com

Remember: The fixes go in the code, but the bugs are found in the data!

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019