@@ -2677,11 +2677,19 @@ static int test_bug5194(MYSQL *mysql)
26772677 check_mysql_rc (rc , mysql );
26782678
26792679 my_bind = (MYSQL_BIND * ) malloc (MAX_PARAM_COUNT * sizeof (MYSQL_BIND ));
2680+ FAIL_UNLESS (my_bind , "Not enough memory" );
26802681 query = (char * ) malloc (strlen (query_template ) +
26812682 MAX_PARAM_COUNT * CHARS_PER_PARAM + 1 );
2683+ if (!query )
2684+ free (my_bind );
2685+ FAIL_UNLESS (query , "Not enough memory" );
26822686 param_str = (char * ) malloc (COLUMN_COUNT * CHARS_PER_PARAM );
2683-
2684- FAIL_IF (my_bind == 0 || query == 0 || param_str == 0 , "Not enough memory" );
2687+ if (!param_str )
2688+ {
2689+ free (my_bind );
2690+ free (query );
2691+ }
2692+ FAIL_UNLESS (param_str , "Not enough memory" );
26852693
26862694 stmt = mysql_stmt_init (mysql );
26872695
@@ -5164,18 +5172,28 @@ static int test_maxparam(MYSQL *mysql)
51645172 MYSQL_BIND * bind ;
51655173
51665174 bind = calloc (65535 , sizeof * bind );
5175+ FAIL_UNLESS (bind , "Not enough memory" );
51675176
51685177 rc = mysql_query (mysql , "DROP TABLE IF EXISTS t1" );
5178+ if (rc )
5179+ free (bind );
51695180 check_mysql_rc (rc , mysql );
51705181
51715182 rc = mysql_query (mysql , "CREATE TABLE t1 (a int)" );
5183+ if (rc )
5184+ free (bind );
51725185 check_mysql_rc (rc , mysql );
51735186
51745187 buffer = calloc (1 , mem );
5188+ if (!buffer )
5189+ free (bind );
5190+ FAIL_UNLESS (bind , "Not enough memory" );
51755191 strcpy (buffer , query );
51765192 for (i = 0 ; i < 65534. ; i ++ )
51775193 strcat (buffer , ",(?)" );
51785194 rc = mysql_stmt_prepare (stmt , SL (buffer ));
5195+ if (rc )
5196+ free (bind );
51795197 check_stmt_rc (rc , stmt );
51805198
51815199 for (i = 0 ; i < 65534 ; i ++ )
@@ -5185,9 +5203,13 @@ static int test_maxparam(MYSQL *mysql)
51855203 }
51865204
51875205 rc = mysql_stmt_bind_param (stmt , bind );
5206+ if (rc )
5207+ free (bind );
51885208 check_stmt_rc (rc , stmt );
51895209
51905210 rc = mysql_stmt_execute (stmt );
5211+ if (rc )
5212+ free (bind );
51915213 check_stmt_rc (rc , stmt );
51925214
51935215 FAIL_IF (mysql_stmt_affected_rows (stmt ) != 65535 , "Expected affected_rows=65535" );
0 commit comments