summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2019-03-06 01:19:48 +0100
committerSergei Golubchik <serg@mariadb.org>2019-03-06 15:28:27 +0100
commit65070beffd2e9279145b48d1f27c517b6588e543 (patch)
treed2b4be92114036d7d5e69d35de70a241ff3bfd1a
parent2b4027e63369329a1491c1d9402ff2ddf30d3d64 (diff)
downloadmariadb-git-65070beffd2e9279145b48d1f27c517b6588e543.tar.gz
MDEV-13818 CREATE INDEX leaks memory if running out of undo log space
free already allocated indexes if row_merge_create_index() fails This fixes innodb.alter_crash failure in ASAN_OPTIONS="abort_on_error=1" runs
-rw-r--r--storage/innobase/handler/handler0alter.cc5
-rw-r--r--storage/innobase/row/row0merge.cc1
2 files changed, 5 insertions, 1 deletions
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index a2a13b90e3a..d0b577f7535 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -4860,7 +4860,7 @@ new_clustered_failed:
/* Create the indexes in SYS_INDEXES and load into dictionary. */
- for (ulint a = 0; a < ctx->num_to_add_index; a++) {
+ for (int a = 0; a < ctx->num_to_add_index; a++) {
if (index_defs[a].ind_type & DICT_VIRTUAL
&& ctx->num_to_drop_vcol > 0 && !new_clustered) {
@@ -4877,6 +4877,9 @@ new_clustered_failed:
if (!ctx->add_index[a]) {
error = ctx->trx->error_state;
DBUG_ASSERT(error != DB_SUCCESS);
+ while (--a >= 0) {
+ dict_mem_index_free(ctx->add_index[a]);
+ }
goto error_handling;
}
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index c1ee3d29ce1..92528ed4d2c 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -4418,6 +4418,7 @@ row_merge_create_index(
this index, to ensure read consistency. */
ut_ad(index->trx_id == trx->id);
} else {
+ dict_mem_index_free(index);
index = NULL;
}