[Mesa-dev] [PATCH] libutils/mipmap.c: Fixed possible memory leak
Amarnath Valluri
amarnath.valluri at intel.com
Fri Jun 10 14:29:54 UTC 2016
Thanks Brian, for quick review.
I am obsoletely fine with the changes.
- Amarnath
On Friday 10 June 2016 05:20 PM, Brian Paul wrote:
> On 06/10/2016 05:30 AM, Amarnath Valluri wrote:
>> In case of malloc() failure memory allocated for both 'srcImage' and
>> 'dstImage'
>> is leaked.
>>
>> Signed-off-by: Amarnath Valluri <amarnath.valluri at intel.com>
>> ---
>> src/libutil/mipmap.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/libutil/mipmap.c b/src/libutil/mipmap.c
>> index c475c96..1f718a6 100644
>> --- a/src/libutil/mipmap.c
>> +++ b/src/libutil/mipmap.c
>> @@ -4509,7 +4509,11 @@ static int gluBuild2DMipmapLevelsCore(GLenum
>> target, GLint internalFormat,
>> glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels);
>> glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length);
>> glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes);
>> - return GLU_OUT_OF_MEMORY;
>> + free(srcImage); /*if you get to here, a srcImage has always
>> been malloc'ed*/
>> + if (dstImage) { /* if it's non-rectangular and only 1 level */
>> + free(dstImage);
>> + }
>> + return GLU_OUT_OF_MEMORY;
>> }
>>
>> /* copy image from srcImage into newMipmapImage by rows */
>>
>
> I'll push this patch with a few minor changes:
> 1. fix indentation to match surrounding code.
> 2. remove if-test around the second free(). free(NULL) is a no-op.
> 3. remove unneeded comments.
> 4. List the bug URL in the check-in comment.
>
> Sound OK?
>
> Thanks for the patch!
>
> -Brian
>
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
More information about the mesa-dev
mailing list