commit d1d00465cd115b5d9bdb95aa8525f5bd65633f64 Author: Dmitry Lenev Date: Tue Jun 2 13:45:24 2026 +0200 Bug #120602 Memory leak in fil_ibd_same_as_default_path() ASAN reported memory leak in fil_ibd_same_as_default_path() in several tests. This unsophisticated memory leak was introduced in MySQL 8.0.46 by fix for "Bug#38169053: MySQL 8.0.39/40 crashed due to Assertion failure error when running TRUNCATE" (https://github.com/mysql/mysql-server/commit/b63930df6330cfbf81ea9d8e4c9eace3e16c3703). The problem was that default_path string was allocated but not properly freed on all return paths from this function. Ensure that default_path string is freed in all cases by using RAII helper. diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index b4c323c3220..14958e7d4c5 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -9884,6 +9884,8 @@ static bool fil_ibd_same_as_default_path(const char *space_name, /* Build the implicit default path for this table name under @@datadir. */ char *default_path = Fil_path::make("", space_name, IBD); + auto guard = create_scope_guard([&]() { ut::free(default_path); }); + if (default_path == nullptr || default_path[0] == '\0') { return false; } @@ -9907,7 +9909,6 @@ static bool fil_ibd_same_as_default_path(const char *space_name, df_found.close(); df_default.close(); - ut::free(default_path); return same; }