diff options
author | unknown <hf@deer.(none)> | 2004-02-20 12:18:06 +0400 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2004-02-20 12:18:06 +0400 |
commit | 3711e24a86d1ab8bc354ea1fe88687645504d3cc (patch) | |
tree | 5b50ada35f43308fd47649acec8b0cdb83a35c14 /libmysql | |
parent | 3804200122762f88d9af28851610dc0c6dcbe0e8 (diff) | |
download | mariadb-git-3711e24a86d1ab8bc354ea1fe88687645504d3cc.tar.gz |
Fix for #1429 (Segfault in mysql_stmt_close)
Problem was that we checked for existing connection in stmt_close
and did not free(stmt) if it's closed (that didn't work well with
embedded)
I just added new flag to the stmt_close and now we check it instead
of connection
libmysql/client_settings.h:
declaration changed
libmysql/libmysql.c:
stmt_close and it's calls modified
sql-common/client.c:
stmt_close call modified
Diffstat (limited to 'libmysql')
-rw-r--r-- | libmysql/client_settings.h | 2 | ||||
-rw-r--r-- | libmysql/libmysql.c | 15 |
2 files changed, 9 insertions, 8 deletions
diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index 4558f0f2abe..5ce0e021782 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -22,7 +22,7 @@ extern my_string mysql_unix_port; CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION) sig_handler pipe_sig_handler(int sig __attribute__((unused))); -my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list); +my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list, my_bool skip_free); void read_user_name(char *name); my_bool send_file_to_server(MYSQL *mysql, const char *filename); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 8da695c5a9d..d9b01caf0ea 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -89,7 +89,7 @@ static void append_wild(char *to,char *end,const char *wild); sig_handler pipe_sig_handler(int sig); static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, const char *from, ulong length); -my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list); +my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list, my_bool skip_free); static my_bool mysql_client_init= 0; static my_bool org_my_init_done= 0; @@ -1666,14 +1666,14 @@ mysql_prepare(MYSQL *mysql, const char *query, ulong length) } if (simple_command(mysql, COM_PREPARE, query, length, 1)) { - stmt_close(stmt, 1); + stmt_close(stmt, 1, 0); DBUG_RETURN(0); } init_alloc_root(&stmt->mem_root,8192,0); if ((*mysql->methods->read_prepare_result)(mysql, stmt)) { - stmt_close(stmt, 1); + stmt_close(stmt, 1, 0); DBUG_RETURN(0); } @@ -3312,7 +3312,7 @@ my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt) } -my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list) +my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list, my_bool skip_free) { MYSQL *mysql; DBUG_ENTER("mysql_stmt_close"); @@ -3321,7 +3321,8 @@ my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list) if (!(mysql= stmt->mysql)) { - my_free((gptr) stmt, MYF(MY_WME)); + if (!skip_free) + my_free((gptr) stmt, MYF(MY_WME)); DBUG_RETURN(0); } mysql_stmt_free_result(stmt); @@ -3329,7 +3330,7 @@ my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list) { char buff[4]; int4store(buff, stmt->stmt_id); - if (simple_command(mysql, COM_CLOSE_STMT, buff, 4, 1)) + if (skip_free || simple_command(mysql, COM_CLOSE_STMT, buff, 4, 1)) { set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, mysql->net.sqlstate); @@ -3350,7 +3351,7 @@ my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list) my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt) { - return stmt_close(stmt, 0); + return stmt_close(stmt, 0, 0); } /* |