[Piglit] [PATCH v2] arb_bindless_texture: Fix memory leaks.

Vinson Lee vlee at freedesktop.org
Fri Apr 14 22:20:39 UTC 2017


CID: 1405026
Fixes: 66676a2fcd48 ("add API-related tests for ARB_bindless_texture")
Signed-off-by: Vinson Lee <vlee at freedesktop.org>
---
 tests/spec/arb_bindless_texture/legal.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/spec/arb_bindless_texture/legal.c b/tests/spec/arb_bindless_texture/legal.c
index 0084e7dea965..741cb634c8f0 100644
--- a/tests/spec/arb_bindless_texture/legal.c
+++ b/tests/spec/arb_bindless_texture/legal.c
@@ -48,8 +48,10 @@ call_TexSubImage_when_texture_is_referenced(void *data)
 	tex = piglit_integer_texture(GL_RGBA32I, 16, 16, 0, 0);
 
 	glGetTextureHandleARB(tex);
-	if (!piglit_check_gl_error(GL_NO_ERROR))
+	if (!piglit_check_gl_error(GL_NO_ERROR)) {
+		free(img);
 		return PIGLIT_FAIL;
+	}
 
 	/* The ARB_bindless_texture spec says:
 	 *
@@ -61,10 +63,10 @@ call_TexSubImage_when_texture_is_referenced(void *data)
 	 */
 	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 16, 16, GL_RGBA_INTEGER,
 			GL_INT, img);
+	free(img);
 	if (!piglit_check_gl_error(GL_NO_ERROR))
 		return PIGLIT_FAIL;
 
-	free(img);
 	return PIGLIT_PASS;
 }
 
@@ -126,10 +128,10 @@ call_CompressedTexSubImage_when_texture_is_referenced(void *data)
 	glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 16, 16,
 				  GL_COMPRESSED_RGBA_BPTC_UNORM, size,
 				  compressed);
+	free(compressed);
 	if (!piglit_check_gl_error(GL_NO_ERROR))
 		return PIGLIT_FAIL;
 
-	free(compressed);
 	return PIGLIT_PASS;
 }
 
-- 
2.9.3



More information about the Piglit mailing list