Re:System memory allocator free operation zeroes out dealloc...
by ncmncm on Thursday September 22, 2022 @05:10PM
(#32944674)
Writing random values to freed memory would mostly work, at some cost to performance.
The memory could get allocated again before it is re-used, and whatever is put in it might be less trappy than a random value. And, of course, a random value might not trap.
Better is not to do things that result in referring to dead memory: easy in modern C++, apparently difficult in C.
The memory could get allocated again before it is re-used, and whatever is put in it might be less trappy than a random value. And, of course, a random value might not trap.
Better is not to do things that result in referring to dead memory: easy in modern C++, apparently difficult in C.