Menu

#1 Check return codes everywhere

open
nobody
None
5
2007-03-08
2007-03-08
No

Some checks for return codes are missing.

Examples:
Would you like to add more error handling for return values from "malloc" in functions like "main" and "h264_new"?
http://h264bitstream.svn.sourceforge.net/viewvc/h264bitstream/trunk/h264bitstream/h264_analyze.c?revision=8&view=markup
http://h264bitstream.svn.sourceforge.net/viewvc/h264bitstream/trunk/h264bitstream/h264_stream.c?revision=6&view=markup

Discussion

  • Alex I

    Alex I - 2007-05-24

    Logged In: YES
    user_id=994715
    Originator: NO

    in general, yes more error handling is great and i'm working on that. the main area where this is necessary is checking for read/write beyond the end of array in bs_*. right now all those functions check internally so it won't crash but there's no way for the calling function to know that it has tried to go beyond and report the error up.

    checking the return value of malloc is imho not very useful on unix systems since malloc always succeeds due to overcommitted virtual memory; the first sign of a problem is the application is killed when you try to access the allocated memory (if the system has run out of memory or you're over the resource limit).

    i am very interested in any other specific suggestions for places where you think error checking may be useful.

     
  • Markus Elfring

    Markus Elfring - 2007-05-24

    Logged In: YES
    user_id=572001
    Originator: YES

    1. Not all malloc() implementations use an OOM killer.
    http://en.wikipedia.org/wiki/Out_of_memory

    2. Do you care for failed output and log messages?

    3. Can the tool "http://splint.org/" help to find any remaining issues?

     

Log in to post a comment.