summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2022-08-02 11:42:20 +0200
committerSergei Golubchik <serg@mariadb.org>2022-08-02 20:10:37 +0200
commit07a670b8848e00672b2274a30f44e79cdba20376 (patch)
tree061785b7aa5f39cd49f9fdb3077841be906c2413 /client
parent92b0a367aa9f4602f99d28eae5776c679984ac88 (diff)
downloadmariadb-git-07a670b8848e00672b2274a30f44e79cdba20376.tar.gz
MDEV-23097 heap-use-after-free in mysqlimport
mysqlimport starts many worker threads. when one of the worker encounters an error, it frees global memory and calls exit(). it suppresses memory leak detector, because, as the comment says "dirty exit, some threads are still running", indeed, it cannot free the memory from other threads. but precisely because some threads are still running, they might use this global memory, so it cannot be freed. fix: if we know that some threads are still running and accept that we cannot free all memory anyway, let's not free global allocations either
Diffstat (limited to 'client')
-rw-r--r--client/mysqlimport.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/client/mysqlimport.c b/client/mysqlimport.c
index 880d3ff07cf..9d83e65535d 100644
--- a/client/mysqlimport.c
+++ b/client/mysqlimport.c
@@ -524,16 +524,18 @@ static void safe_exit(int error, MYSQL *mysql)
if (mysql)
mysql_close(mysql);
- mysql_library_end();
-#ifdef HAVE_SMEM
- my_free(shared_memory_base_name);
-#endif
- free_defaults(argv_to_free);
- my_free(opt_password);
if (error)
sf_leaking_memory= 1; /* dirty exit, some threads are still running */
else
+ {
+ mysql_library_end();
+#ifdef HAVE_SMEM
+ my_free(shared_memory_base_name);
+#endif
+ free_defaults(argv_to_free);
+ my_free(opt_password);
my_end(my_end_arg); /* clean exit */
+ }
exit(error);
}