From 2645bda5f20ab10bc26dc1cb69f91b5505c1faae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 9 May 2017 13:40:42 +0300 Subject: MDEV-12253 post-fix: Do not leak memory in crash recovery This fixes the cmake -DWITH_ASAN test failure that was mentioned in commit f9cc391863ab962e8c8a8a8a676d730498eb8d6f (merging MDEV-12253 from 10.1 to 10.2). fil_parse_write_crypt_data(): If the tablespace is not found, invoke fil_space_destroy_crypt_data(&crypt_data) to properly free the created object. With this, the test encryption.innodb-redo-badkey still reports "Missing MLOG_FILE_NAME or MLOG_FILE_DELETE before MLOG_CHECKPOINT" but does not fail. The misleading message should be corrected, maybe as part of MDEV-12699. --- storage/innobase/fil/fil0crypt.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'storage/innobase/fil') diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 7f35e86bbc8..c7d740bc6af 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -502,16 +502,16 @@ fil_parse_write_crypt_data( ptr += len; /* update fil_space memory cache with crypt_data */ - fil_space_t* space = fil_space_acquire_silent(space_id); - - if (space) { + if (fil_space_t* space = fil_space_acquire_silent(space_id)) { crypt_data = fil_space_set_crypt_data(space, crypt_data); fil_space_release(space); - } - - /* Check is used key found from encryption plugin */ - if (crypt_data->should_encrypt() && !crypt_data->is_key_found()) { - *err = DB_DECRYPTION_FAILED; + /* Check is used key found from encryption plugin */ + if (crypt_data->should_encrypt() + && !crypt_data->is_key_found()) { + *err = DB_DECRYPTION_FAILED; + } + } else { + fil_space_destroy_crypt_data(&crypt_data); } return ptr; -- cgit v1.2.1