3 ms·
> One of the most common bugs in C (in my experience) is forgetting to check the error return on a malloc call. Very unlikely. 1. it won't happen in regular u
by wott 9y ago
> One of the most common bugs in C (in my experience) is forgetting to check the error return on a malloc call.
Very unlikely.
1. it won't happen in regular use, only if your are asking for a huge amount of memory (possibly by mistake), or the system is already full and you will likely experience problems with the whole system (freezes, instability, processes killed, etc) and not just with your program.
2. it will never happen in Linux, because in the classical setup, malloc() never returns NULL, even when there is no memory available.
So you have to have those conditions + a return value unchecked for the bug to have a chance to appear. There are thousands of other bug sources.
- nwmcsween 9y agoThe 'classical' setup is horribly broken and relying it just makes more broken code.