[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 08/15] qstring: Add qstring_wrap_str()
From: |
Eric Blake |
Subject: |
Re: [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
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v6 12/15] qapi: Support pretty printing in JSON output visitor, (continued)
- [Qemu-devel] [PATCH v6 12/15] qapi: Support pretty printing in JSON output visitor, Eric Blake, 2016/10/10
- [Qemu-devel] [PATCH v6 11/15] qapi: Add JSON output visitor, Eric Blake, 2016/10/10
- [Qemu-devel] [PATCH v6 10/15] tests: Test qobject_to_json() pretty formatting, Eric Blake, 2016/10/10
- [Qemu-devel] [PATCH v6 14/15] qapi: Add 'any' support to JSON output, Eric Blake, 2016/10/10
- [Qemu-devel] [PATCH v6 13/15] qobject: Implement qobject_to_json() atop JSON visitor, Eric Blake, 2016/10/10
- [Qemu-devel] [PATCH v6 09/15] qobject: Consolidate qobject_to_json() calls, Eric Blake, 2016/10/10
- [Qemu-devel] [PATCH v6 08/15] qstring: Add qstring_wrap_str(), Eric Blake, 2016/10/10
- [Qemu-devel] [PATCH v6 15/15] qemu-img: Use new JSON output formatter, Eric Blake, 2016/10/10
- Re: [Qemu-devel] [PATCH v6 00/15] Add qapi-to-JSON visitor, Marc-André Lureau, 2016/10/11