[Mesa-dev] [PATCH] r600/sb: Fix memory leak

Nicolai Hähnle nhaehnle at gmail.com
Mon Jan 30 14:16:14 UTC 2017


Nice find!

On 29.01.2017 19:10, Bartosz Tomczyk wrote:
> ---
>  src/gallium/drivers/r600/sb/sb_valtable.cpp | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/r600/sb/sb_valtable.cpp b/src/gallium/drivers/r600/sb/sb_valtable.cpp
> index a8b7b49cd4..d31a1b76d5 100644
> --- a/src/gallium/drivers/r600/sb/sb_valtable.cpp
> +++ b/src/gallium/drivers/r600/sb/sb_valtable.cpp
> @@ -241,6 +241,7 @@ void value::remove_use(const node *n) {
>  	{
>  		// TODO assert((*it)->kind == kind) ?
>  		// TODO assert((*it)->arg == arg) ?
> +		delete *it;
>  		uses.erase(it);

The delete should really be after the erase.

Cheers,
Nicolai

>  	}
>  }
> @@ -290,7 +291,12 @@ bool value::is_prealloc() {
>  }
>
>  void value::delete_uses() {
> -	uses.erase(uses.begin(), uses.end());
> +	for (uselist::iterator it = uses.begin(); it != uses.end(); ++it)
> +	{
> +		delete *it;
> +	}
> +
> +	uses.clear();
>  }
>
>  void ra_constraint::update_values() {
>



More information about the mesa-dev mailing list