Mercurial > hg > forks > geeqie
changeset 2687:be871c22e64c
Fix for some small memory leaks
author | Tomasz Golinski <tomaszg@math.uwb.edu.pl> |
---|---|
date | Sat, 30 Dec 2017 13:53:50 +0100 |
parents | 11b11d8531fe |
children | 00da4e1bf128 d89f4d37676c |
files | src/ui_fileops.c |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ui_fileops.c Sat Dec 30 13:46:51 2017 +0100 +++ b/src/ui_fileops.c Sat Dec 30 13:53:50 2017 +0100 @@ -555,9 +555,15 @@ if (lstat_utf8(sl, &st) && S_ISLNK(st.st_mode)) { gchar *link_target; + ssize_t i; - link_target = g_malloc(PATH_MAX + 1); - readlink(sl, link_target, st.st_size); + link_target = g_malloc(st.st_size + 1); + i = readlink(sl, link_target, st.st_size); + if (i<0) + { + g_free(link_target); + goto orig_copy; // try a "normal" copy + } link_target[st.st_size] = '\0'; if (link_target[0] != G_DIR_SEPARATOR) // if it is a relative symlink @@ -582,6 +588,7 @@ } else // could not get absolute path, got some error instead { + g_free(link_target); g_free(absolute); goto orig_copy; // so try a "normal" copy }