[BUG] memory leak in src/file.c::copy_dir_dir()
- From: Denys Vlasenko <vda linux googlemail com>
- To: mc-devel gnome org
- Subject: [BUG] memory leak in src/file.c::copy_dir_dir()
- Date: Thu, 2 Jul 2009 19:03:30 +0200
Hi,
Noticed this memory leak while working on another problem.
Watch variable d:
char *d;
/* First get the mode of the source dir */
retry_src_stat:
if ((*ctx->stat_func) (s, &cbuf)) {
return_status =
file_error (_(" Cannot stat source directory \"%s\" \n %s "), s);
if (return_status == FILE_RETRY)
goto retry_src_stat;
return return_status;
}
if (is_in_linklist (dest_dirs, s, &cbuf)) {
/* Don't copy a directory we created before (we don't want to copy.
infinitely if a directory is copied into itself) */
/* FIXME: should there be an error message and FILE_SKIP? - Norbert */
return FILE_CONT;
}
d = strutils_shell_unescape (_d);
/* Hmm, hardlink to directory??? - Norbert */
/* FIXME: In this step we should do something
in case the destination already exist */
/* Check the hardlinks */
if (ctx->preserve && cbuf.st_nlink > 1
&& check_hardlinks (s, d, &cbuf) == 1) {
/* We have made a hardlink - no more processing is necessary */
g_free(d);
return return_status;
}
if (!S_ISDIR (cbuf.st_mode)) {
return_status =
file_error (_(" Source \"%s\" is not a directory \n %s "), s);
if (return_status == FILE_RETRY)
//bug: leaking d
goto retry_src_stat;
g_free(d);
return return_status;
}
The fix is simple: move g_free(d) up two lines.
Please, can someone with write access do this? Thanks.
--
vda
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]