SF.net SVN: geany: [1363] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Sat Mar 3 13:34:15 UTC 2007
Revision: 1363
http://svn.sourceforge.net/geany/?rev=1363&view=rev
Author: ntrel
Date: 2007-03-03 05:34:15 -0800 (Sat, 03 Mar 2007)
Log Message:
-----------
Fix memory leak with utils_remove_ext_from_filename().
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/build.c
trunk/src/utils.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-03-03 13:14:41 UTC (rev 1362)
+++ trunk/ChangeLog 2007-03-03 13:34:15 UTC (rev 1363)
@@ -3,6 +3,8 @@
* src/build.c:
Moved all code for checking and creating the geany run script
temporary file from build_run_cmd() to prepare_run_script().
+ * src/build.c, src/utils.c:
+ Fix memory leak with utils_remove_ext_from_filename().
2007-03-02 Enrico Tröger <enrico.troeger at uvena.de>
Modified: trunk/src/build.c
===================================================================
--- trunk/src/build.c 2007-03-03 13:14:41 UTC (rev 1362)
+++ trunk/src/build.c 2007-03-03 13:34:15 UTC (rev 1363)
@@ -513,7 +513,9 @@
long_executable = utils_remove_ext_from_filename(locale_filename);
#ifdef G_OS_WIN32
+ tmp = long_executable;
long_executable = g_strconcat(long_executable, ".exe", NULL);
+ g_free(tmp);
#endif
// only check for existing executable, if executable is required by %e
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2007-03-03 13:14:41 UTC (rev 1362)
+++ trunk/src/utils.c 2007-03-03 13:34:15 UTC (rev 1363)
@@ -717,20 +717,22 @@
* a newly allocated string */
gchar *utils_remove_ext_from_filename(const gchar *filename)
{
- gchar *result = g_malloc0(strlen(filename));
gchar *last_dot = strrchr(filename, '.');
- gint i = 0;
+ gchar *result;
+ gint i;
if (filename == NULL) return NULL;
if (! last_dot) return g_strdup(filename);
+ result = g_malloc(strlen(filename)); // assumes extension is small, so extra bytes don't matter
+ i = 0;
while ((filename + i) != last_dot)
{
result[i] = filename[i];
i++;
}
-
+ result[i] = 0;
return result;
}
@@ -1218,7 +1220,7 @@
if (nblock)
g_io_channel_set_flags(ioc, G_IO_FLAG_NONBLOCK, NULL);
-
+
g_io_channel_set_encoding(ioc, NULL, NULL);
/*
if (! g_get_charset(&encoding))
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