Ticket #1393 (closed defect: fixed)
Memory leak in src/file.c::copy_dir_dir()
| Reported by: | andrew_b | Owned by: | andrew_b |
|---|---|---|---|
| Priority: | critical | Milestone: | 4.7.0-pre1 |
| Component: | mc-core | Version: | master |
| Keywords: | Cc: | ||
| Blocked By: | Blocking: | ||
| Branch state: | Votes for changeset: | committed-master |
Description
Bugreport in mc-devel@ mail list from vda:
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.
Change History
comment:1 Changed 16 years ago by andrew_b
- Owner set to andrew_b
- Status changed from new to accepted
comment:2 Changed 16 years ago by andrew_b
- severity changed from no branch to on review
Created 1393_copy_dir_dir_memleak branch. Parent branch: master.
Initial changeset:80006e30e37436f7ba06dfd08608c7e20d1a3dcd
comment:3 Changed 16 years ago by winnie
- Votes for changeset set to winnie
looks fine, thanks for the patch
comment:4 Changed 16 years ago by angel_il
- Votes for changeset changed from winnie to winnie angel_il
- severity changed from on review to approved
comment:5 Changed 16 years ago by angel_il
- Votes for changeset changed from winnie angel_il to winnie
- severity changed from approved to on review
comment:6 Changed 16 years ago by angel_il
- Votes for changeset changed from winnie to winnie angel_il
- severity changed from on review to approved
comment:7 Changed 16 years ago by andrew_b
- Status changed from accepted to testing
- Resolution set to fixed
- severity changed from approved to merged
Merged to master.
changeset:80006e30e37436f7ba06dfd08608c7e20d1a3dcd
Note: See
TracTickets for help on using
tickets.
