Received: from eggs.gnu.org ([208.118.235.92]:50351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvpLs-0000C9-6v for qemu-devel@nongnu.org; Thu, 17 Jan 2013 08:17:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvpLq-0006n7-Gd for qemu-devel@nongnu.org; Thu, 17 Jan 2013 08:17:52 -0500 From: Markus Armbruster References: <1358357540-29862-1-git-send-email-armbru@redhat.com> <1358357540-29862-9-git-send-email-armbru@redhat.com> <20130117112420.GJ2586@stefanha-thinkpad.redhat.com> Date: Thu, 17 Jan 2013 14:17:47 +0100 In-Reply-To: <20130117112420.GJ2586@stefanha-thinkpad.redhat.com> (Stefan Hajnoczi's message of "Thu, 17 Jan 2013 12:24:20 +0100") Message-ID: <87k3rcrls4.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 08/11] qemu-log: Plug trivial memory leak in cpu_set_log_filename() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org Stefan Hajnoczi 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.