[PATCH 1/6] Fixed some memory leaks in windows.c and main.c
Lubomir I. Ivanov
neolit123 at gmail.com
Sat Feb 9 11:29:56 PST 2013
From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
windows.c:subsurface_gettext_domainpath():
- memory at pointer returned from g_win32_getlocale() should be released
main.c:setup_system_prefs()
- it seems all calls to <os_file>:system_default_filename()
return a pre-allocated buffer, therefore we don't need to call strdup()
on the result itself.
Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
main.c | 2 +-
windows.c | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c
index a22524f..1ddcb3b 100644
--- a/main.c
+++ b/main.c
@@ -281,7 +281,7 @@ static void setup_system_prefs(void)
const char *env;
default_prefs.divelist_font = strdup(system_divelist_default_font);
- default_prefs.default_filename = strdup(system_default_filename());
+ default_prefs.default_filename = system_default_filename();
env = getenv("LC_MEASUREMENT");
if (!env)
diff --git a/windows.c b/windows.c
index 9087c9e..3db08de 100644
--- a/windows.c
+++ b/windows.c
@@ -232,8 +232,10 @@ const char *subsurface_gettext_domainpath(char *argv0)
/* first hackishly make sure that the LANGUAGE information is correctly set up
* in the environment */
char buffer[80];
- snprintf(buffer, sizeof(buffer), "LANGUAGE=%s.UTF-8", g_win32_getlocale());
+ gchar *locale = g_win32_getlocale();
+ snprintf(buffer, sizeof(buffer), "LANGUAGE=%s.UTF-8", locale);
putenv(buffer);
+ g_free(locale);
/* always use translation directory relative to install location, regardless of argv0 */
return "./share/locale";
}
--
1.7.11.msysgit.0
More information about the subsurface
mailing list