DragonFly BSD
DragonFly bugs List (threaded) for 2004-10
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: cu coredumps


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 27 Oct 2004 11:44:15 -0700 (PDT)

    (1) No you cannot safely use data that has been free()'d.  Not ever.  The
	original free() 15+ years ago had the side effect that the last
	free()'d data could still be used until the next free(), but nobody
	in their right mind programs to that spec any more.

    (2) No, you cannot assume that freed data will always cause a seg fault,
	or contain good or bad data. 

    (3) Stop worrying about performance for operations that are executed once
	and will take far less then 1 microsecond, and stop worrying about
	memory leaks for one-time string operations.  Don't worry about
	freeing the old data in this case.

    (4) Use asprintf().  Do not use malloc+str*() functions.  Especially do
	not use str*() functions for this sort of thing.  Just use asprintf().

						-Matt




[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]