[geany/geany] 5d6203: Fix "leaks" of geany_run_script (bug 975)

elextr git-noreply at xxxxx
Tue Jan 21 22:15:25 UTC 2014


Branch:      refs/heads/master
Author:      elextr <elextr at gmail.com>
Committer:   elextr <elextr at gmail.com>
Date:        Tue, 21 Jan 2014 22:15:25 UTC
Commit:      5d62030667b917a942ff05562807ef761a120728
             https://github.com/geany/geany/commit/5d62030667b917a942ff05562807ef761a120728

Log Message:
-----------
Fix "leaks" of geany_run_script (bug 975)

In build_run_cmd() the script was not deleted when any one of
several errors occurred.  The errors are not related to script
contents so it makes no sense to leave the script.

Also fixes failure to delete script if a working dir was set.


Modified Paths:
--------------
    src/build.c

Modified: src/build.c
9 files changed, 8 insertions(+), 1 deletions(-)
===================================================================
@@ -995,6 +995,7 @@ static GPid build_run_cmd(GeanyDocument *doc, guint cmdindex)
 		gchar *locale_term_cmd = NULL;
 		gint argv_len, i;
 		gchar **argv = NULL;
+		gchar *script_path = NULL;
 
 		/* get the terminal path */
 		locale_term_cmd = utils_get_locale_from_utf8(tool_prefs.term_cmd);
@@ -1005,6 +1006,8 @@ static GPid build_run_cmd(GeanyDocument *doc, guint cmdindex)
 				_("Could not parse terminal command \"%s\" "
 					"(check Terminal tool setting in Preferences)"), tool_prefs.term_cmd);
 			run_info[cmdindex].pid = (GPid) 1;
+			script_path = g_build_filename(working_dir, RUN_SCRIPT_CMD, NULL);
+			g_unlink(script_path);
 			goto free_strings;
 		}
 
@@ -1022,6 +1025,8 @@ static GPid build_run_cmd(GeanyDocument *doc, guint cmdindex)
 				_("Could not find terminal \"%s\" "
 					"(check path for Terminal tool setting in Preferences)"), tool_prefs.term_cmd);
 			run_info[cmdindex].pid = (GPid) 1;
+			script_path = g_build_filename(working_dir, RUN_SCRIPT_CMD, NULL);
+			g_unlink(script_path);
 			goto free_strings;
 		}
 
@@ -1035,8 +1040,9 @@ static GPid build_run_cmd(GeanyDocument *doc, guint cmdindex)
 		{
 			geany_debug("g_spawn_async() failed: %s", error->message);
 			ui_set_statusbar(TRUE, _("Process failed (%s)"), error->message);
-			g_unlink(RUN_SCRIPT_CMD);
 			g_error_free(error);
+			script_path = g_build_filename(working_dir, RUN_SCRIPT_CMD, NULL);
+			g_unlink(script_path);
 			error = NULL;
 			run_info[cmdindex].pid = (GPid) 0;
 		}
@@ -1050,6 +1056,7 @@ static GPid build_run_cmd(GeanyDocument *doc, guint cmdindex)
 		free_strings:
 		g_strfreev(argv);
 		g_free(locale_term_cmd);
+		g_free(script_path);
 	}
 
 	g_free(working_dir);



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list