qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] ossaudio: fix memory leak


From: Markus Armbruster
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] ossaudio: fix memory leak
Date: Thu, 25 Jun 2015 08:55:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

<address@hidden> writes:

> From: Gonglei <address@hidden>
>
> Variable "conf" going out of scope leaks the storage
> it points to in line 856.
>
> Signed-off-by: Gonglei <address@hidden>
> ---
> v2:
>  using an better way to avoid memory leak. (Markus) 
> ---
>  audio/ossaudio.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/audio/ossaudio.c b/audio/ossaudio.c
> index 11e76a1..94b473b 100644
> --- a/audio/ossaudio.c
> +++ b/audio/ossaudio.c
> @@ -848,14 +848,11 @@ static OSSConf glob_conf = {
>  
>  static void *oss_audio_init (void)
>  {
> -    OSSConf *conf = g_malloc(sizeof(OSSConf));
> -    *conf = glob_conf;
> -
> -    if (access(conf->devpath_in, R_OK | W_OK) < 0 ||
> -        access(conf->devpath_out, R_OK | W_OK) < 0) {
> +    if (access(glob_conf.devpath_in, R_OK | W_OK) < 0 ||
> +        access(glob_conf.devpath_out, R_OK | W_OK) < 0) {
>          return NULL;
>      }
> -    return conf;
> +    return g_memdup(&glob_conf, sizeof(glob_conf));
>  }
>  
>  static void oss_audio_fini (void *opaque)

Reviewed-by: Markus Armbruster <address@hidden>

Now I get to add g_memdup() to scripts/coverity-model.c...



reply via email to

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