[CONC-218] 2nd mariadb_stmt_execute_direct with parameters causes crashes appliction Created: 2016-11-28  Updated: 2016-11-29  Resolved: 2016-11-29

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: None
Fix Version/s: 3.0.1

Type: Task Priority: Major
Reporter: Lawrin Novitsky Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None
Environment:

10.2 server, C/C master



 Description   

static int conc_new_issue(MYSQL *mysql)

{ MYSQL_STMT *stmt= mysql_stmt_init(mysql); MYSQL_BIND bind[2]; bind[0].buffer_type = MYSQL_TYPE_LONG; bind[0].buffer = (void *)&id; bind[0].buffer_length = 4; bind[0].is_null = &is_null[0]; bind[0].length = NULL;// &length[0]; bind[0].error = &error[0]; mysql_stmt_attr_set(stmt, STMT_ATTR_PREBIND_PARAMS, &param_count); check_stmt_rc(mysql_stmt_bind_param(stmt, bind), stmt); check_stmt_rc(mariadb_stmt_execute_direct(stmt, "SELECT ?", -1), stmt); check_stmt_rc(mysql_stmt_store_result(stmt), stmt); check_stmt_rc(mysql_stmt_free_result(stmt), stmt); //mysql_stmt_close(stmt); //stmt= mysql_stmt_init(mysql); param_count= 1; mysql_stmt_attr_set(stmt, STMT_ATTR_PREBIND_PARAMS, &param_count); check_stmt_rc(mysql_stmt_bind_param(stmt, bind), stmt); check_stmt_rc(mariadb_stmt_execute_direct(stmt, "SELECT ?", -1), stmt); mysql_stmt_close(stmt); return OK; }

Yes, if close stmt between 2 calls, everything will work fine.



 Comments   
Comment by Georg Richter [ 2016-11-29 ]

Reusing statement might lead to unexpected behavior - mariadb_stmt_execute_direct().

If we want to allow reusing we need to reset statement in mysql_stmt_attr_set when setting number of prebind parameters.

Generated at Thu Feb 08 03:03:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.