qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [PATCH v2 08/11] qemu-log: Plug trivial memory leak i


From: Markus Armbruster
Subject: Re: [Qemu-trivial] [PATCH v2 08/11] qemu-log: Plug trivial memory leak in cpu_set_log_filename()
Date: Thu, 17 Jan 2013 14:17:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux)

Stefan Hajnoczi <address@hidden> writes:

> On Wed, Jan 16, 2013 at 06:32:17PM +0100, Markus Armbruster wrote:
>> diff --git a/qemu-log.c b/qemu-log.c
>> index 64a1b88..30c8b01 100644
>> --- a/qemu-log.c
>> +++ b/qemu-log.c
>> @@ -21,10 +21,12 @@
>>  #include "qemu/log.h"
>>  
>>  #ifdef WIN32
>> -static const char *logfilename = "qemu.log";
>> +#define DEFAULT_LOGFILENAME "qemu.log"
>>  #else
>> -static const char *logfilename = "/tmp/qemu.log";
>> +#define DEFAULT_LOGFILENAME "/tmp/qemu.log"
>>  #endif
>> +
>> +static const char *logfilename;
> [...]
>> @@ -84,6 +88,7 @@ void qemu_set_log(int log_flags, bool use_own_buffers)
>>  
>>  void cpu_set_log_filename(const char *filename)
>>  {
>> +    g_free((void *)logfilename);
>
> Might as well drop the const from the variable declaration to indicate
> that we allocate/free this string.

Never thought of const that way.  Dropping const from logfilename is
fine with me.

I wish free()'s parameter was const void *.  Can't be changed now.  Sad
that glib didn't get it right either.



reply via email to

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