From 2d81c70a410949a07375b370b9a1329081605a6f Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Sun, 26 Apr 2020 03:07:59 +0200 Subject: [PATCH] Fix max_param test: Allocate memory for parameters on heap instead of stack. --- unittest/libmariadb/ps_bugs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/unittest/libmariadb/ps_bugs.c b/unittest/libmariadb/ps_bugs.c index 1ea218d6..aa8eabf7 100644 --- a/unittest/libmariadb/ps_bugs.c +++ b/unittest/libmariadb/ps_bugs.c @@ -5121,7 +5121,9 @@ static int test_maxparam(MYSQL *mysql) int val= 1; size_t mem= strlen(query) + 1 + 4 * 65535 + 1; MYSQL_STMT *stmt= mysql_stmt_init(mysql); - MYSQL_BIND bind[65535]; + MYSQL_BIND* bind; + + bind = calloc(sizeof(MYSQL_BIND), 65535); rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); check_mysql_rc(rc, mysql); @@ -5136,7 +5138,6 @@ static int test_maxparam(MYSQL *mysql) rc= mysql_stmt_prepare(stmt, SL(buffer)); check_stmt_rc(rc, stmt); - memset(bind, 0, sizeof(MYSQL_BIND) * 65535); for (i=0; i < 65534; i++) { bind[i].buffer_type= MYSQL_TYPE_LONG; @@ -5158,6 +5159,7 @@ static int test_maxparam(MYSQL *mysql) FAIL_IF(mysql_stmt_errno(stmt) != ER_PS_MANY_PARAM, "Expected ER_PS_MANY_PARAM error"); mysql_stmt_close(stmt); + free(bind); return OK; }