diff mbox series

[v1,5/5] Fix double free issue in qemu_set_log_filename().

Message ID 20191112150105.2498-6-robert.foley@linaro.org (mailing list archive)
State New, archived
Headers show
Series Make the qemu_logfile handle thread safe. | expand

Commit Message

Robert Foley Nov. 12, 2019, 3:01 p.m. UTC
After freeing the logfilename, we set logfilename to NULL, in case of an
error which returns without setting logfilename.

Signed-off-by: Robert Foley <robert.foley@linaro.org>
---
v1
    - This is new in the patch v1.
---
 util/log.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Alex Bennée Nov. 12, 2019, 6:23 p.m. UTC | #1
Robert Foley <robert.foley@linaro.org> writes:

> After freeing the logfilename, we set logfilename to NULL, in case of an
> error which returns without setting logfilename.
>
> Signed-off-by: Robert Foley <robert.foley@linaro.org>

As this fixes an existing bug I would put this at the start of the
series. Otherwise:

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
> v1
>     - This is new in the patch v1.
> ---
>  util/log.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/util/log.c b/util/log.c
> index 802b8de42e..1eed74788c 100644
> --- a/util/log.c
> +++ b/util/log.c
> @@ -148,6 +148,7 @@ void qemu_set_log_filename(const char *filename, Error **errp)
>      char *pidstr;
>
>      g_free(logfilename);
> +    logfilename = NULL;
>
>      pidstr = strstr(filename, "%");
>      if (pidstr) {


--
Alex Bennée
diff mbox series

Patch

diff --git a/util/log.c b/util/log.c
index 802b8de42e..1eed74788c 100644
--- a/util/log.c
+++ b/util/log.c
@@ -148,6 +148,7 @@  void qemu_set_log_filename(const char *filename, Error **errp)
     char *pidstr;
 
     g_free(logfilename);
+    logfilename = NULL;
 
     pidstr = strstr(filename, "%");
     if (pidstr) {