diff options
author | thek@adventure.(none) <> | 2007-11-19 17:59:44 +0100 |
---|---|---|
committer | thek@adventure.(none) <> | 2007-11-19 17:59:44 +0100 |
commit | 1794242b24cc0f958af48db9019d95aed06cf589 (patch) | |
tree | 38840a14fc2e8e497e55ade1ff13ac6ef617c0d5 /sql/mysqld.cc | |
parent | 82767a0a45dd2a8c356bd9a5c8e8971dd15d4b05 (diff) | |
download | mariadb-git-1794242b24cc0f958af48db9019d95aed06cf589.tar.gz |
Bug #31153 calling stored procedure crashes server if available memory is low
When the server was out of memory it crashed because of invalid memory access.
This patch adds detection for failed memory allocations and make the server
output a proper error message.
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 08c2b60fa79..89d7f3272ad 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2489,7 +2489,12 @@ static int my_message_sql(uint error, const char *str, myf MyFlags) thd->query_error= 1; // needed to catch query errors during replication if (!thd->no_warnings_for_error) + { + thd->no_warnings_for_error= TRUE; push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, error, str); + thd->no_warnings_for_error= FALSE; + } + /* thd->lex->current_select == 0 if lex structure is not inited (not query command (COM_QUERY)) @@ -4295,8 +4300,13 @@ pthread_handler_t handle_connections_sockets(void *arg __attribute__((unused))) sock == unix_sock ? VIO_LOCALHOST: 0)) || my_net_init(&thd->net,vio_tmp)) { - if (vio_tmp) - vio_delete(vio_tmp); + /* + Only delete the temporary vio if we didn't already attach it to the + NET object. The destructor in THD will delete any initialized net + structure. + */ + if (vio_tmp && thd->net.vio != vio_tmp) + vio_delete(vio_tmp); else { (void) shutdown(new_sock, SHUT_RDWR); |