malloc does not return null when out of memory
Alban Hertroys
dalroi at solfertje.student.utwente.nl
Fri Jul 25 15:13:41 PDT 2003
On 24 Jul, Pete French punched keys in this particular order:
> Its not bogus - the trouble is that you cant tell at the time malloc returns
> whether the pointer will be useable or not. You only find that out when
> you try and use it, and whether theres any space or not depends oon what
> else may have munched up (or released) memory between you making the call
> to malloc() and actually writing to the location returned.
This looks similar to the problem with mktemp(). Maybe it is possible to
solve this in a similar way? For example, by allocating memory and
filling it in the same call?
That probably would mean that all the software should switch to a new
way of allocating memory, but it's a start...
--
Alban Hertroys http://solfertje.student.utwente.nl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This person has performed an illegal operation
and will be shot down.
More information about the freebsd-stable
mailing list