[PATCH v2 13/25] [libx11] The NEWTABLE macro missed freeing its allocated memory on subsequent memory allocation errors. Added call to Xfree.

Alan Coopersmith alan.coopersmith at oracle.com
Mon Jan 31 23:44:30 PST 2011


On 01/31/11 04:02 AM, Erkki Seppälä wrote:
> Variable "table" goes out of scope
> 
> Reviewed-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira at nokia.com>
> Signed-off-by: Erkki Seppälä <erkki.seppala at vincit.fi>
> ---
>  src/Xrm.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/src/Xrm.c b/src/Xrm.c
> index 21f0af3..3e68c37 100644
> --- a/src/Xrm.c
> +++ b/src/Xrm.c
> @@ -842,8 +842,10 @@ static void PutEntry(
>  	nprev = NodeBuckets(table); \
>      } else { \
>  	table->leaf = 1; \
> -	if (!(nprev = (NTable *)Xmalloc(sizeof(VEntry *)))) \
> +	if (!(nprev = (NTable *)Xmalloc(sizeof(VEntry *)))) {\
> +	    Xfree(table); \
>  	    return; \
> +        } \
>  	((LTable)table)->buckets = (VEntry *)nprev; \
>      } \
>      *nprev = (NTable)NULL; \

Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list