Commit 853458d4 authored by marko's avatar marko

row_drop_table_for_mysql(): Before calling

dict_table_remove_from_cache(table) and thus freeing the memory
allocated for the table, copy the table name.  This avoids reading
freed memory when name == table->name.

Approved by Sunny.
parent d9288383
...@@ -2932,8 +2932,6 @@ row_drop_table_for_mysql( ...@@ -2932,8 +2932,6 @@ row_drop_table_for_mysql(
ulint err; ulint err;
const char* table_name; const char* table_name;
ulint namelen; ulint namelen;
char* dir_path_of_temp_table = NULL;
ibool success;
ibool locked_dictionary = FALSE; ibool locked_dictionary = FALSE;
pars_info_t* info = NULL; pars_info_t* info = NULL;
...@@ -3228,14 +3226,20 @@ check_next_foreign: ...@@ -3228,14 +3226,20 @@ check_next_foreign:
} else { } else {
ibool is_path; ibool is_path;
const char* name_or_path; const char* name_or_path;
mem_heap_t* heap;
heap = mem_heap_create(200);
/* Clone the name, in case it has been allocated
from table->heap, which will be freed by
dict_table_remove_from_cache(table) below. */
name = mem_heap_strdup(heap, name);
space_id = table->space; space_id = table->space;
if (table->dir_path_of_temp_table != NULL) { if (table->dir_path_of_temp_table != NULL) {
dir_path_of_temp_table = mem_strdup(
table->dir_path_of_temp_table);
is_path = TRUE; is_path = TRUE;
name_or_path = dir_path_of_temp_table; name_or_path = mem_heap_strdup(
heap, table->dir_path_of_temp_table);
} else { } else {
is_path = FALSE; is_path = FALSE;
name_or_path = name; name_or_path = name;
...@@ -3268,13 +3272,7 @@ check_next_foreign: ...@@ -3268,13 +3272,7 @@ check_next_foreign:
"InnoDB: of table "); "InnoDB: of table ");
ut_print_name(stderr, trx, TRUE, name); ut_print_name(stderr, trx, TRUE, name);
fprintf(stderr, ".\n"); fprintf(stderr, ".\n");
} else if (!fil_delete_tablespace(space_id)) {
goto funct_exit;
}
success = fil_delete_tablespace(space_id);
if (!success) {
fprintf(stderr, fprintf(stderr,
"InnoDB: We removed now the InnoDB" "InnoDB: We removed now the InnoDB"
" internal data dictionary entry\n" " internal data dictionary entry\n"
...@@ -3292,6 +3290,8 @@ check_next_foreign: ...@@ -3292,6 +3290,8 @@ check_next_foreign:
err = DB_ERROR; err = DB_ERROR;
} }
} }
mem_heap_free(heap);
} }
funct_exit: funct_exit:
...@@ -3301,10 +3301,6 @@ funct_exit: ...@@ -3301,10 +3301,6 @@ funct_exit:
row_mysql_unlock_data_dictionary(trx); row_mysql_unlock_data_dictionary(trx);
} }
if (dir_path_of_temp_table) {
mem_free(dir_path_of_temp_table);
}
trx->op_info = ""; trx->op_info = "";
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment