[PATCH:libXxf86vm 1/4] Improve error handling in XF86VidModeGetMonitor()

walter harms wharms at bfs.de
Mon Apr 15 04:47:16 PDT 2013



Am 14.04.2013 17:16, schrieb Alan Coopersmith:
> On 04/14/13 04:28 AM, walter harms wrote:
>>      if (rep.vendorLength) {
>> -       if (!(monitor->vendor = (char *)Xcalloc(rep.vendorLength + 1,
>> 1))) {
>> -           _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 +
>> -                     ((rep.vendorLength+3) & ~3) +
>> ((rep.modelLength+3) & ~3));
>> -           return False;
>> -       }
>> +       monitor->vendor = Xcalloc(rep.vendorLength + 1, 1);
>> +       if (monitor->vendor == NULL)
>> +           result = False;
>>      } else {
>>         monitor->vendor = NULL;
>>      }
>>
>> i do not understand this, do you realy want monitor->vendor = NULL;
>> when monitor->vendor = Xcalloc(rep.vendorLength + 1, 1); succeeds ?`
> 
> You're missing the nesting there - the monitor->vendor = NULL; is the
> else clause for if (rep.vendorLength) - i.e. if the length is 0, set
> it to NULL, otherwise try to allocate memory for it.
> 
ok, i see.
In this case i suggest to do the monitor->vendor = NULL first
and check length later. that removes one indent level and guaranties a
proper initialization.

re,
 wh


More information about the xorg-devel mailing list