[Piglit] [PATCH 1/3] cl: Don't use variable length array

Jan Vesely jan.vesely at rutgers.edu
Fri Dec 12 11:33:22 PST 2014


Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
 tests/cl/program/program-tester.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/cl/program/program-tester.c b/tests/cl/program/program-tester.c
index d6dbc55..3905679 100644
--- a/tests/cl/program/program-tester.c
+++ b/tests/cl/program/program-tester.c
@@ -517,13 +517,15 @@ regex_get_str(char** dst,
               unsigned int index,
               int cflags)
 {
-	regmatch_t pmatch[index+1];
+	regmatch_t *pmatch = calloc(index+1, sizeof(*pmatch));
+	bool ret = false;
 
 	if(regex_get_matches(src, pattern, pmatch, index+1, cflags)) {
-		return regex_get_match_str(dst, src, pmatch, index);
+		ret = regex_get_match_str(dst, src, pmatch, index);
 	}
 
-	return false;
+	free(pmatch);
+	return ret;
 }
 
 bool
-- 
2.1.0



More information about the Piglit mailing list