SF.net SVN: geany:[4147] trunk

elextr at users.sourceforge.net elextr at xxxxx
Thu Sep 3 04:32:06 UTC 2009


Revision: 4147
          http://geany.svn.sourceforge.net/geany/?rev=4147&view=rev
Author:   elextr
Date:     2009-09-03 04:32:05 +0000 (Thu, 03 Sep 2009)

Log Message:
-----------
Ensure uses of filename are protected against nulls when running
a build command and give status message if not.

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-09-03 03:40:21 UTC (rev 4146)
+++ trunk/ChangeLog	2009-09-03 04:32:05 UTC (rev 4147)
@@ -3,6 +3,9 @@
  * src/build.c, src/filetypes.h, src/filetypes.c
    Only write filetype config files when build command or regex is
    actually changed.  Removed commented code in src/filetypes.c.
+ * src/build.c
+   Ensure uses of filename are protected against nulls when running
+   a build command and give status message if not.
 
 
 2009-09-01  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/build.c
===================================================================
--- trunk/src/build.c	2009-09-03 03:40:21 UTC (rev 4146)
+++ trunk/src/build.c	2009-09-03 04:32:05 UTC (rev 4147)
@@ -504,7 +504,7 @@
 	gchar* ret_str; /* to be freed when not in use anymore */
 
 	stack = g_string_new(src);
-	if (doc!=NULL)
+	if (doc!=NULL && doc->file_name!=NULL)
 	{
 		filename = utils_get_utf8_from_locale(doc->file_name);
 
@@ -534,7 +534,7 @@
 	else if (strstr(stack->str, "%p"))
 	{   /* fall back to %d */
 		ui_set_statusbar(FALSE, _("failed to substitute %%p, no project active"));
-		if (doc!=NULL)
+		if (doc!=NULL && filename!=NULL)
 			replacement = g_path_get_dirname(filename);
 	}
 
@@ -568,7 +568,12 @@
 	gint	 stderr_fd;
 #endif
 
-	g_return_val_if_fail(doc!=NULL || dir!=NULL, (GPid) 1);
+	if(!( (doc!=NULL && NZV(doc->file_name)) || NZV(dir) ))
+	{
+		geany_debug("Failed to run command with no working directory");
+		ui_set_statusbar(TRUE, _("Process failed, no working directory"));
+		return (GPid)1;
+	}
 
 	if (doc!=NULL)
 		clear_errors(doc);
@@ -712,7 +717,7 @@
 	if (! result)
 	{
 		ui_set_statusbar(TRUE, _("Failed to execute \"%s\" (start-script could not be created)"),
-			cmd_string);
+			NZV(cmd_string) ? cmd_string: NULL);
 	}
 
 	utils_free_pointers(4, cmd_string, tmp, executable, locale_filename, NULL);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list