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

Re: [libvirt] [PATCH] usbFindBusByVendor: don't leak a DIR buffer and FD



According to Jim Meyering on 1/25/2010 8:55 AM:
> Subject: [PATCH] hostusb: closedir only if non-NULL; rename labels: s/error/cleanup/
> 
> * src/util/hostusb.c (usbSysReadFile): Rename labels s/error/cleanup/
> (usbFindBusByVendor): Likewise.  And closedir only if non-NULL.
> @@ -150,8 +150,9 @@ static int usbFindBusByVendor(virConnectPtr conn,
>      else
>          ret = 0;
> 
> -error:
> -    closedir (dir);
> +cleanup:
> +    if (dir)
> +        closedir (dir);

Should errno be saved and restored around this point, to avoid it being
arbitrarily changed by closedir?

-- 
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9 byu net

Attachment: signature.asc
Description: OpenPGP digital signature


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