Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
12.2
-
None
-
None
Description
The following mtr script:
remove_file /abc-non-existing;
|
remove_file /abc-non-existing;
|
leads to a memory leak detected by ASAN:
Direct leak of 40 byte(s) in 1 object(s) allocated from:
|
#0 0x7624a4d2277b in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:67
|
#1 0x605261458104 in my_malloc /src/mariadb/mysys/my_malloc.c:93
|
#2 0x605261468202 in init_dynamic_string /src/mariadb/mysys/string.c:39
|
#3 0x605261248d0f in check_command_args(st_command*, char const*, command_arg const*, int, char) /src/mariadb/client/mysqltest.cc:1338
|
#4 0x60526125c988 in do_remove_file(st_command*) /src/mariadb/client/mysqltest.cc:3774
|
#5 0x60526128fdb0 in main /src/mariadb/client/mysqltest.cc:10495
|
#6 0x7624a342a577 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
|
#7 0x7624a342a63a in __libc_start_main_impl ../csu/libc-start.c:360
|
#8 0x6052612437c4 in _start (/src/mariadb/client/mariadb-test+0x60c7c4) (BuildId: 6b4259489e49ec23d1291ca73d19d77c027c6582)
|
Adding a freeing of the parameter in case of bad_path() fixes the issue:
if (bad_path(ds_filename.str))
|
+ {
|
+ dynstr_free(&ds_filename);
|
DBUG_VOID_RETURN;
|
+ }
|
I checked all callers of check_command_args(), and several callers (e.g. var_set_query_get_value() and do_perl()) do free memory in case of earlier return. So I came as far as adding freeing of necessary arguments from do_remove_file() in similar places, I'll pin down the patch. If it's okay I'll make a PR.