diff options
author | unknown <thek@adventure.(none)> | 2007-11-19 17:59:44 +0100 |
---|---|---|
committer | unknown <thek@adventure.(none)> | 2007-11-19 17:59:44 +0100 |
commit | bb681dbc883343ed2c503c15833720f8da499317 (patch) | |
tree | 38840a14fc2e8e497e55ade1ff13ac6ef617c0d5 /sql/sql_base.cc | |
parent | f4b6234c489c4b8c3242828953b8ae71e5653c59 (diff) | |
download | mariadb-git-bb681dbc883343ed2c503c15833720f8da499317.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.
sql/mysqld.cc:
Don't try to push_warning from within push_warning. It will cause a recursion
until the stack is consumed.
If my_net_init fails (for example: because of OOM) the temporary vio object
might have been attached to the thd object already. This will cause a double
free on the vio object when the thd object is deleted later on and the server
will crash.
sql/sp_head.cc:
Added check for out-of-memory on a 'new' operation.
Refactored reset_lex method to return a error state code instead of void.
Initialize the mem-root with init_sql_alloc to get a basic error handler for
memory allocation problems. This alone won't prevent the server from crashing,
NULL pointers have to be accounted for as well.
sql/sp_head.h:
Use the throw() clause in operator new, to indicate to the compiler that
memory allocation can fail and return NULL, so that the compiler should
generate code to check for NULL before invoking C++ constructors, to be
crash safe.
sql/sql_base.cc:
Use init_sql_alloc to get basic out-of-memory error handling.
sql/sql_lex.h:
Use the throw() clause in operator new, to indicate to the compiler that
memory allocation can fail and return NULL, so that the compiler should
generate code to check for NULL before invoking C++ constructors, to be
crash safe.
sql/sql_prepare.cc:
Use init_sql_alloc to get basic out-of-memory error handling.
sql/sql_yacc.yy:
Check for memory allocation failures where it matters.
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 289924ff418..7ceed4e15d2 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -80,7 +80,6 @@ bool Prelock_error_handler::safely_trapped_errors() return ((m_handled_errors > 0) && (m_unhandled_errors == 0)); } - TABLE *unused_tables; /* Used by mysql_test */ HASH open_cache; /* Used by mysql_test */ @@ -2643,7 +2642,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags) temporary mem_root for new .frm parsing. TODO: variables for size */ - init_alloc_root(&new_frm_mem, 8024, 8024); + init_sql_alloc(&new_frm_mem, 8024, 8024); thd->current_tablenr= 0; restart: |