[libvirt] [PATCH] Fix closedir usage in virNumaGetPages

Eric Blake eblake at redhat.com
Mon Jun 23 15:34:39 UTC 2014


On 06/23/2014 05:46 AM, Michal Privoznik wrote:

>> -    closedir(dir);
>> +    if (dir)
>> +        closedir(dir);
>>       VIR_FREE(path);
>>       return ret;
>>   }
>>
> 
> So why is free(NULL) safe on FreeBSD then? I'd call this a libc bug not
> a libvirt one. But since even we already have such borken design
> (remember our publir vir*Free() APIs?) I can live with this patch.

free(NULL) is explicitly required by C (and therefore POSIX) to be safe.
 closedir(NULL) is intentionally unspecified by POSIX, and therefore
unsafe.  It would be nice if the two had similar requirements, but as
POSIX was merely standardizing existing practice, we are stuck with them
being different in behavior.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140623/dd40f34f/attachment-0001.sig>


More information about the libvir-list mailing list