On 04/ 4/11 03:24 PM, Nicolas Kaiser wrote:
> * Ian Romanick <[email protected]>:
>> On 04/02/2011 11:17 AM, Nicolas Kaiser wrote:
>>> diff --git a/src/mga_dri.c b/src/mga_dri.c
>>> index 2723dd8..8b1d751 100644
>>> --- a/src/mga_dri.c
>>> +++ b/src/mga_dri.c
>>> @@ -92,24 +92,24 @@ static Bool MGAInitVisualConfigs( ScreenPtr pScreen )
>>>     case 16:
>>>        numConfigs = 8;
>>>  
>>> -      pConfigs = (__GLXvisualConfig*)xcalloc( sizeof(__GLXvisualConfig),
>>> +      pConfigs = (__GLXvisualConfig*)calloc( 1, sizeof(__GLXvisualConfig) *
>>>                                             numConfigs );  
>>
>> Why?  I think the correct thing is the switch numConfigs and sizeof(...)
>> in all these cases.  Calling calloc like that is just silly.
> 
> That's the way I saw the wrapper do it in /usr/include/xorg/os.h:
> 
> #define xcalloc(_num, _size) Xcalloc((unsigned long)(_num)*(unsigned 
> long)(_size))

Notice that Xcalloc took a single argument, like malloc, not two like calloc.
When calling calloc, call it correctly - it's unlikely that the multiplication
will overflow, but calloc is more likely to catch it if it does than if you do
the multiplication yourself.

-- 
        -Alan Coopersmith-        [email protected]
         Oracle Solaris Platform Engineering: X Window System

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to