[Mesa-dev] [PATCH] mesa: Fix memory leak in _mesa_get_uniform_location.

Kenneth Graunke kenneth at whitecape.org
Fri Mar 23 12:02:06 PDT 2012


On 03/23/2012 12:09 AM, Vinson Lee wrote:
> Fixes Coverity resource leak defect.
>
> NOTE: This is a candidate for the 8.0 branch.
>
> Signed-off-by: Vinson Lee<vlee at freedesktop.org>
> ---
>   src/mesa/main/uniform_query.cpp |    4 +++-
>   1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
> index 991df78..da41ee8 100644
> --- a/src/mesa/main/uniform_query.cpp
> +++ b/src/mesa/main/uniform_query.cpp
> @@ -905,8 +905,10 @@ _mesa_get_uniform_location(struct gl_context *ctx,
>         name_copy[i-1] = '\0';
>
>         offset = strtol(&name[i], NULL, 10);
> -      if (offset<  0)
> +      if (offset<  0) {
> +	 free(name_copy);
>   	 return -1;
> +      }
>
>         array_lookup = true;
>      } else {

Nice catch.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>


More information about the mesa-dev mailing list