Stefan Hajnoczi <[email protected]> writes:
> On Tue, Apr 02, 2013 at 07:47:26PM +0800, Wenchao Xia wrote:
>> diff --git a/qemu-img.c b/qemu-img.c
>> index 5b229a9..032f68c 100644
>> --- a/qemu-img.c
>> +++ b/qemu-img.c
>> @@ -1558,18 +1558,24 @@ static void dump_snapshots(BlockDriverState *bs)
>> {
>> QEMUSnapshotInfo *sn_tab, *sn;
>> int nb_sns, i;
>> - char buf[256];
>> + GString *buf = g_string_new(NULL);
>>
>> nb_sns = bdrv_snapshot_list(bs, &sn_tab);
>> if (nb_sns <= 0)
>> return;
>
> Leaks buf.
Trivially avoided my moving the initialization behind the return.
>> diff --git a/savevm.c b/savevm.c
>> index e4e0008..ce0bbe1 100644
>> --- a/savevm.c
>> +++ b/savevm.c
>> @@ -2466,7 +2466,7 @@ void do_info_snapshots(Monitor *mon, const QDict
>> *qdict)
>> int nb_sns, i, ret, available;
>> int total;
>> int *available_snapshots;
>> - char buf[256];
>> + GString *buf = NULL;
>>
>> bs = bdrv_snapshots();
>> if (!bs) {
>> @@ -2509,11 +2509,16 @@ void do_info_snapshots(Monitor *mon, const
>> QDict *qdict)
>> }
>>
>> if (total > 0) {
>
> Please declare buf here since it is only used in this scope.
Matter of taste. I'd keep it where it is :)