summaryrefslogtreecommitdiff
path: root/sql/sp_head.h
diff options
context:
space:
mode:
authorunknown <thek@adventure.(none)>2007-11-19 17:59:44 +0100
committerunknown <thek@adventure.(none)>2007-11-19 17:59:44 +0100
commitbb681dbc883343ed2c503c15833720f8da499317 (patch)
tree38840a14fc2e8e497e55ade1ff13ac6ef617c0d5 /sql/sp_head.h
parentf4b6234c489c4b8c3242828953b8ae71e5653c59 (diff)
downloadmariadb-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/sp_head.h')
-rw-r--r--sql/sp_head.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/sql/sp_head.h b/sql/sp_head.h
index ebe40ce9c87..cb243dd2503 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -191,10 +191,10 @@ public:
Security_context m_security_ctx;
static void *
- operator new(size_t size);
+ operator new(size_t size) throw ();
static void
- operator delete(void *ptr, size_t size);
+ operator delete(void *ptr, size_t size) throw ();
sp_head();
@@ -254,7 +254,7 @@ public:
}
// Resets lex in 'thd' and keeps a copy of the old one.
- void
+ bool
reset_lex(THD *thd);
// Restores lex in 'thd' from our copy, but keeps some status from the