Re: [PATCH] daemon: Don't try to free an unsigned int in error paths

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

 



2011/4/22 Eric Blake <eblake@xxxxxxxxxx>:
> On 04/22/2011 10:31 AM, Christophe Fergeau wrote:
>> On Fri, Apr 22, 2011 at 10:17:01AM -0600, Eric Blake wrote:
>>> On 04/22/2011 10:11 AM, Matthias Bolte wrote:
>>>> Â Â Â Â ÂremoteDispatchError(rerr);
>>>> - Â Â Â ÂVIR_FREE(ret->names.names_len);
>>>> + Â Â Â ÂVIR_FREE(ret->names.names_val);
>>>
>>> And to think I missed those in the huge patch. ÂOops.
>>
>> Maybe VIR_FREE should be changed to something like
>>
>> -# define VIR_FREE(ptr) virFree(&(ptr))
>> +# define VIR_FREE(ptr) \
>> + Â Âdo { void *check_type = (ptr); virFree(&(check_type)); } while (0)
>
> Not quite. ÂThat assigns check_type to NULL, rather than the intended
> assignment of ptr.
>
> But the idea has merit; I'll see if I can come up with a variant that
> still evaluates ptr only once, by wrapping the type check in a sizeof hack.
>
>> I also get more warnings about casting from const to non-const, this can
>> be avoided by making check_type const void *, but maybe these warnings
>> indicate that something that shouldn't be freed is freed.
>
> How many warnings? ÂIf it's only a handful, we should start
> investigating; if it's lots, then I'm not sure how much it buys us.
>

I just took a look at it and the first instances are mostly const
char* used for allocated strings. I didn't spot a real error yet. But
I'll leaf this one to you and finish my generator series instead :)

Matthias

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]