From 25315360bd8bcfaeb956a6397733ce094c9752bc Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Fri, 20 Apr 2012 14:40:04 +0400 Subject: [PATCH] (mc_setup_by_args): fixed memory leaks. Signed-off-by: Andrew Borodin --- src/args.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/args.c b/src/args.c index c871f696e..7aac3dc6d 100644 --- a/src/args.c +++ b/src/args.c @@ -655,6 +655,7 @@ mc_setup_by_args (int argc, char **argv, GError ** error) char *fname; struct stat st; vfs_path_t *tmp_vpath, *fname_vpath; + gboolean ok; fname = g_strndup (tmp, p - 1 - tmp); tmp_vpath = vfs_path_from_str (tmp); @@ -663,7 +664,11 @@ mc_setup_by_args (int argc, char **argv, GError ** error) * Check that the file before the colon actually exists. * If it doesn't exist, revert to the old behavior. */ - if (mc_stat (tmp_vpath, &st) == -1 && mc_stat (fname_vpath, &st) != -1) + ok = mc_stat (tmp_vpath, &st) == -1 && mc_stat (fname_vpath, &st) != -1; + vfs_path_free (tmp_vpath); + vfs_path_free (fname_vpath); + + if (ok) { mc_run_param0 = fname; mc_args__edit_start_line = atoi (p); @@ -673,8 +678,6 @@ mc_setup_by_args (int argc, char **argv, GError ** error) g_free (fname); goto try_plus_filename; } - vfs_path_free (tmp_vpath); - vfs_path_free (fname_vpath); } else { -- 2.11.4.GIT