[Piglit] [PATCH 5/6] util/wfl: check for calloc() failure

Emil Velikov emil.l.velikov at gmail.com
Tue Mar 29 22:45:00 UTC 2016


Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 tests/util/piglit-framework-gl/piglit_wfl_framework.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/util/piglit-framework-gl/piglit_wfl_framework.c b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
index b2fe417..cb8514e 100644
--- a/tests/util/piglit-framework-gl/piglit_wfl_framework.c
+++ b/tests/util/piglit-framework-gl/piglit_wfl_framework.c
@@ -154,9 +154,11 @@ concat_attrib_lists(const int32_t a[], const int32_t b[])
 	int b_copy_size = 2 * b_length * sizeof(int32_t);
 
 	int32_t *r = calloc(1, r_size);
-	memcpy(r, a, a_copy_size);
-	memcpy(r + 2 * a_length, b, b_copy_size);
-	r[2 * r_length] = 0;
+	if (r) {
+		memcpy(r, a, a_copy_size);
+		memcpy(r + 2 * a_length, b, b_copy_size);
+		r[2 * r_length] = 0;
+	}
 	return r;
 }
 
-- 
2.6.2



More information about the Piglit mailing list