[Piglit] [PATCH] copy-pixels: Fix memory leak.

Vinson Lee vlee at freedesktop.org
Wed Jul 13 23:26:42 UTC 2016


Fix resource leak defect reported by Coverity.

CID: 1363040
Fixes: 3529e325ff98 ("Rewrite copy-pixels test")
Signed-off-by: Vinson Lee <vlee at freedesktop.org>
---
 tests/general/copy-pixels.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tests/general/copy-pixels.c b/tests/general/copy-pixels.c
index 308868612fa8..cff1cb65adeb 100644
--- a/tests/general/copy-pixels.c
+++ b/tests/general/copy-pixels.c
@@ -47,10 +47,10 @@ test_color_copypix(int x, int y)
 	bool pass = true;
 	GLuint tex;
 
-	const float *expected = piglit_rgbw_image(GL_RGBA,
-						  IMAGE_WIDTH, IMAGE_HEIGHT,
-						  GL_FALSE, /* alpha */
-						  GL_UNSIGNED_NORMALIZED);
+	float *expected = piglit_rgbw_image(GL_RGBA,
+					    IMAGE_WIDTH, IMAGE_HEIGHT,
+					    GL_FALSE, /* alpha */
+					    GL_UNSIGNED_NORMALIZED);
 
 	/* Initialize color data */
 	tex = piglit_rgbw_texture(GL_RGBA, IMAGE_WIDTH, IMAGE_HEIGHT,
@@ -65,6 +65,7 @@ test_color_copypix(int x, int y)
 	glCopyPixels(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, GL_COLOR);
 	pass = piglit_probe_image_color(x, y, IMAGE_WIDTH, IMAGE_HEIGHT,
 					GL_RGBA, expected) && pass;
+	free(expected);
 	return pass;
 }
 
-- 
2.7.4



More information about the Piglit mailing list