-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added malloc return check #579
Conversation
In this case, the program should crash immediately, it should not be tolerant of this |
Not really, malloc can return valid pointers on other function run. (For example if other program with huge ram impact crashed). In all cases that behavior should be processed, maybe not by false return, but exit(ERR_BAD_ALLOC). |
Broke branch by accident |
This is wrong in any case, out of memory errors are now mixed in with the others without any indication of a real problem, and at some point in time the program, when the memory ends completely, will silently stop working. Moreover, if you look closely at where you made changes, you will notice that most of the modified functions are called at startup - lack of memory during a startup should absolutely not be tolerated, no "for example if other program with huge ram impact crashed" will help, you will never go back there. |
How about other option - exit(ERR_BAD_ALLOC) or any other code to indicate memory error? Cause main problem for me is not handled malloc nulls for user in runtime. |
notice that i changed pr due lack of github interface using experience |
Malloc can return null if it can't get memory from os