[Bf-committers] Re: Klocwork source analysis

Stephen Swaney sswaney at centurytel.net
Sun Dec 3 18:25:27 CET 2006


On Sun, Dec 03, 2006 at 05:12:05PM +0100, GSR wrote:
> Hi,
> blender at instinctive.de (2006-12-03 at 1542.56 +0100):
> > So, as discussed many times on the list, it's the old question: Check EACH
> > AND EVERY call to malloc and act accordingly, or check NONE ;)
> 
> If by never, you mean at the high level, I think correct. But the mem
> functions do check and take different measures (in case of problems
> you get the console warning), so that is the probable reason Klocwork
> system did not complain. It is an app, not an human that will realize
> the issue is still there, just masked. To check if that is the reason,
> do a BPY wrapper like MEM_callocN (check pointer and return it or
> return 0).

Just to be clear as to what we are talking about here:

the discussion is about checking the return value from 
PyObject_New(), a high level function that allocates and
initializes a python object.

If there is a problem, a python exception is set and a null
ptr is returned.  At this point, the programmer can simply
propagate the exception or take whatever additional action is
needed.

My personal preference is that blindly dereferencing that
null ptr *not* be part of the additional action.

-- 
Stephen Swaney			
sswaney at centurytel.net



More information about the Bf-committers mailing list