Re: [PATCH] Fix closedir usage in virNumaGetPages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]