Small memory leak when copying file
Description
Each time you copy a file with ctrl + c and ctrl + v, a string is leaked:
Direct leak of 27 byte(s) in 2 object(s) allocated from:
#0 0x650d61b59769 in malloc (/usr/local/bin/thunar+0x488769)
#1 0x7ecd7ed3d762 in g_malloc (/usr/lib/libglib-2.0.so.0+0x62762)
#2 0x7ecd7ed1c141 in g_path_get_basename (/usr/lib/libglib-2.0.so.0+0x41141)
#3 0x650d61d5d308 in thunar_io_jobs_util_next_duplicate_file /home/s/code/thunar/thunar/thunar-io-jobs-util.c:79:18
#4 0x650d61f203e4 in thunar_transfer_job_copy_file /home/s/code/thunar/thunar/thunar-transfer-job.c:733:18
#5 0x650d61f1e110 in thunar_transfer_job_copy_node /home/s/code/thunar/thunar/thunar-transfer-job.c:953:26
#6 0x650d61f17f2b in thunar_transfer_job_execute /home/s/code/thunar/thunar/thunar-transfer-job.c:1730:11
#7 0x7ecd7fcbdaeb in exo_job_scheduler_job_func /home/s/code/exo/exo/exo-job.c:310:14
#8 0x7ecd7eea142d (/usr/lib/libgio-2.0.so.0+0x7a42d)
#9 0x7ecd7eed4db7 (/usr/lib/libgio-2.0.so.0+0xaddb7)
#10 0x7ecd7ed69522 (/usr/lib/libglib-2.0.so.0+0x8e522)
#11 0x7ecd7ed66a44 (/usr/lib/libglib-2.0.so.0+0x8ba44)
#12 0x650d61a90e16 in asan_thread_start(void*) (/usr/local/bin/thunar+0x3bfe16)
#13 0x7ecd7eafd559 (/usr/lib/libc.so.6+0x8b559)
#14 0x7ecd7eb7aa3b (/usr/lib/libc.so.6+0x108a3b)
Debugging
It looks like there are a few potential leaks in thunar_io_jobs_util_next_duplicate_file
:
-
old_filename
is not cleaned up at the end of the function -
old_filename
is not cleaned up before returning on lines 85 and 91 -
parent_file
is not cleaned up before returning on line 91 -
thunar_parent_file
is not cleaned up before returning on line 91
55 GFile*
56 thunar_io_jobs_util_next_duplicate_file (ThunarJob *job,
57 GFile *file,
58 ThunarNextFileNameMode name_mode,
59 GError **error)
60 {
...
78 parent_file = g_file_get_parent (file);
79 old_filename = g_file_get_basename (file);
80 thunar_parent_file = thunar_file_get (parent_file, &err);
81 if (thunar_parent_file == NULL)
82 {
83 g_object_unref (parent_file);
84 g_propagate_error (error, err);
85 return NULL;
86 }
87 thunar_file = thunar_file_get (file, &err);
88 if (thunar_file == NULL)
89 {
90 g_propagate_error (error, err);
91 return NULL;
92 }
...
Version: 3af8e869