qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [Qemu-devel] [PATCH v6 08/15] qstring: Add qstring_wrap


From: Eric Blake
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v6 08/15] qstring: Add qstring_wrap_str()
Date: Tue, 11 Oct 2016 10:04:18 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

On 10/11/2016 06:08 AM, Marc-André Lureau wrote:

>> +++ b/block.c
>> @@ -1640,7 +1640,8 @@ static BlockDriverState
>> *bdrv_append_temp_snapshot(BlockDriverState *bs,
>>      qdict_put(snapshot_options, "file.driver",
>>                qstring_from_str("file"));
>>      qdict_put(snapshot_options, "file.filename",
>> -              qstring_from_str(tmp_filename));
>> +              qstring_wrap_str(tmp_filename));
>> +    tmp_filename = NULL;
>>      qdict_put(snapshot_options, "driver",
>>                qstring_from_str("qcow2"));
>>
>>
> You could also remove g_free(tmp_filename) from the normal return path
> (this may please static analyzers).

No. g_free(NULL) is safe, but we can also reach the 'out' label with
tmp_filename still malloc'd prior to the place where we transfer it
here, so the g_free() in the cleanup label is still required.  The
assignment to NULL here prevents a double free.  The patch is correct as-is.


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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]