mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug #42064: low memory crash when importing hex strings, in
Item_hex_string::Item_hex_string The status of memory allocation in the Lex_input_stream (called from the Parser_state constructor) was not checked which led to a parser crash in case of the out-of-memory error. The solution is to introduce new init() member function in Parser_state and Lex_input_stream so that status of memory allocation can be returned to the caller.
This commit is contained in:
@ -154,6 +154,14 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
|
||||
|
||||
DBUG_ASSERT(alloc_root_inited(mem_root));
|
||||
|
||||
DBUG_EXECUTE_IF("simulate_out_of_memory",
|
||||
{
|
||||
if (mem_root->error_handler)
|
||||
(*mem_root->error_handler)();
|
||||
DBUG_SET("-d,simulate_out_of_memory");
|
||||
DBUG_RETURN((void*) 0); /* purecov: inspected */
|
||||
});
|
||||
|
||||
length+=ALIGN_SIZE(sizeof(USED_MEM));
|
||||
if (!(next = (USED_MEM*) my_malloc(length,MYF(MY_WME))))
|
||||
{
|
||||
@ -176,6 +184,14 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
|
||||
DBUG_PRINT("enter",("root: 0x%lx", (long) mem_root));
|
||||
DBUG_ASSERT(alloc_root_inited(mem_root));
|
||||
|
||||
DBUG_EXECUTE_IF("simulate_out_of_memory",
|
||||
{
|
||||
/* Avoid reusing an already allocated block */
|
||||
if (mem_root->error_handler)
|
||||
(*mem_root->error_handler)();
|
||||
DBUG_SET("-d,simulate_out_of_memory");
|
||||
DBUG_RETURN((void*) 0); /* purecov: inspected */
|
||||
});
|
||||
length= ALIGN_SIZE(length);
|
||||
if ((*(prev= &mem_root->free)) != NULL)
|
||||
{
|
||||
|
Reference in New Issue
Block a user