#281 closed Defect (fixed)
lib/mfile.C should consider "buf" still exists when realloc()==NULL
Reported by: | Joses | Owned by: | davea |
---|---|---|---|
Priority: | Undetermined | Milestone: | Undetermined |
Component: | Client - Build | Version: | |
Keywords: | Cc: |
Description
Please consider the attached file as "highlighting" or "suggesting" fixes for existing realloc() functions since the actual code shown is untested.
Just a note: If realloc() finds out it doesn't have enough memory to do what needs to be done it returns the value NULL (but the existing memory buffer still exists).
Reason for suggesting this enhancement is due to experience with plenty of other programs which don't take NULL into account (this becomes a bit of a problem with computers that have limited RAM computers and limited or (worse) no SWAP space).
Attachments (2)
Change History (7)
Changed 18 years ago by
Attachment: | mfile.C.diff added |
---|
Changed 18 years ago by
Attachment: | parse.C.diff added |
---|
lib/parse.C has a similar problem - highlighted realloc()==NULL
comment:1 Changed 17 years ago by
Owner: | changed from romw to davea |
---|
comment:2 Changed 16 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
It's not clear what problem this fixes
comment:3 Changed 16 years ago by
If realloc()
fails, BOINC loses the pointer to the original buffer, causing a leak, making the lack-of-memory problem worse.
comment:4 Changed 16 years ago by
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
I would consider this just one of the fixes to help harden BOINC a bit more for fault tolerance (especially for machines that have little memory and are misconfigured (especially without any sort of swap file like I've seen on some older linux distros - netbooks could be an example of machines short on memory - and other attributes as well where some sort of sanity check would be of benefit)).
I've seen the number of complains on OpenOffice?'s hunspell drop due to fixes like these (check bugfix #1749709 on sourceforge as an example), and similar alloc and realloc patches for aspell. Realloc is a bit tougher to notice but is fixable too - however, I don't know your preferred stategy with dealing with errors so I left that up to you (I prefer returning stuff back through the stack).
There are also several IO routines that could benefit from some error checks as well, but from experience, it's best to release a few bugs at a time instead of sending in an overwhelming large number of patches - this realloc() being one of several improvement hopefully accepted :-)
comment:5 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
highlight several realloc() functions that should handle existing "buf"