[libvirt] [PATCH 05/10] vbox: Replace atoi with virStrToLong_i

Eric Blake eblake at redhat.com
Tue Mar 30 22:17:44 UTC 2010


On 03/30/2010 10:20 AM, Matthias Bolte wrote:
> ---
>  src/vbox/vbox_tmpl.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
> index 05b075f..07996d4 100644
> --- a/src/vbox/vbox_tmpl.c
> +++ b/src/vbox/vbox_tmpl.c
> @@ -598,7 +598,9 @@ static int PRUnicharToInt(PRUnichar *strUtf16) {
>      if (!strUtf8)
>          return -1;
>  
> -    ret = atoi(strUtf8);
> +    if (virStrToLong_i(strUtf8, NULL, 10, &ret) < 0)
> +        return -1;
> +
>      g_pVBoxGlobalData->pFuncs->pfnUtf8Free(strUtf8);

Oops.  Memory leak if strUtf8 was not valid.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


More information about the libvir-list mailing list