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