[PATCH] compositor: Don't free an uninitialised pointer.

Ryo Munakata ryomnktml at gmail.com
Thu Sep 11 11:08:40 PDT 2014


On Thu, 11 Sep 2014 15:53:15 +0200
Ondřej Majerech <majerech.o at gmail.com> wrote:

> When backend_init returns NULL, we goto out_signals, which wants to
> free(modules), but in this particular code path, modules hasn't been
> initialised leading to a "Double-free or corruption" error message.
> Initialising modules to NULL makes the free a no-op in this scenario.
> 
> Signed-off-by: Ondřej Majerech <majerech.o at gmail.com>
> ---
>  src/compositor.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/compositor.c b/src/compositor.c
> index b0bc86c..a219766 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -4335,7 +4335,8 @@ int main(int argc, char *argv[])
>  	int i, fd;
>  	char *backend = NULL;
>  	char *shell = NULL;
> -	char *modules, *option_modules = NULL;
> +	char *modules = NULL;
> +	char *option_modules = NULL;
>  	char *log = NULL;
>  	char *server_socket = NULL, *end;
>  	int32_t idle_time = 300;

This is right.
I forgot to condider that case when I moved free()s to the end of main().

Reviewed-by: Ryo Munakata <ryomnktml at gmail.com>

Thanks.
-- 
Ryo Munakata <ryomnktml at gmail.com>


More information about the wayland-devel mailing list