Fix inconsistent path generation and checks on win32

- Always check the return value of
  g_win32_get_package_installation_directory_of_module, this call may
  fail and return NULL
- g_build_filename is documented as never returning NULL, no need to
  check for that
This commit is contained in:
Stefan Gehn 2014-07-12 22:03:16 +02:00
parent 33133c63ae
commit 5c40eea518
3 changed files with 11 additions and 20 deletions

View File

@ -788,10 +788,13 @@ read_config(void)
// on windows also load config from INSTALLDIR/etc/gkrellmd.conf // on windows also load config from INSTALLDIR/etc/gkrellmd.conf
#if defined(WIN32) #if defined(WIN32)
install_path = g_win32_get_package_installation_directory_of_module(NULL); install_path = g_win32_get_package_installation_directory_of_module(NULL);
if (install_path != NULL)
{
path = g_build_filename(install_path, "etc", GKRELLMD_CONFIG, NULL); path = g_build_filename(install_path, "etc", GKRELLMD_CONFIG, NULL);
load_config(path); load_config(path);
g_free(install_path);
g_free(path); g_free(path);
g_free(install_path);
}
#endif #endif
_GK.homedir = (gchar *) g_get_home_dir(); _GK.homedir = (gchar *) g_get_home_dir();
@ -1655,11 +1658,8 @@ int main(int argc, char* argv[])
if (install_path != NULL) if (install_path != NULL)
{ {
locale_dir = g_build_filename(install_path, LOCALEDIR, NULL); locale_dir = g_build_filename(install_path, LOCALEDIR, NULL);
if (locale_dir != NULL)
{
bindtextdomain(PACKAGE_D, locale_dir); bindtextdomain(PACKAGE_D, locale_dir);
g_free(locale_dir); g_free(locale_dir);
}
g_free(install_path); g_free(install_path);
} }
#else #else

View File

@ -284,18 +284,14 @@ gkrellmd_plugins_load(void)
g_free(path); g_free(path);
#if defined(WIN32) #if defined(WIN32)
path = NULL;
gchar *install_path; gchar *install_path;
install_path = g_win32_get_package_installation_directory_of_module(NULL); install_path = g_win32_get_package_installation_directory_of_module(NULL);
if (install_path != NULL) if (install_path != NULL)
{ {
path = g_build_filename(install_path, "lib", "gkrellm2", "plugins-gkrellmd", NULL); path = g_build_filename(install_path, "lib", "gkrellm2", "plugins-gkrellmd", NULL);
g_free(install_path);
}
if (path)
{
gkrellmd_plugin_scan(path); gkrellmd_plugin_scan(path);
g_free(path); g_free(path);
g_free(install_path);
} }
#endif #endif

View File

@ -1426,19 +1426,14 @@ gkrellm_make_themes_list(void)
add_themes_to_list(theme_dir, TRUE); add_themes_to_list(theme_dir, TRUE);
#if defined(WIN32) #if defined(WIN32)
theme_dir = NULL;
gchar *install_path; gchar *install_path;
install_path = g_win32_get_package_installation_directory_of_module(NULL); install_path = g_win32_get_package_installation_directory_of_module(NULL);
if (install_path != NULL) if (install_path != NULL)
{ {
theme_dir = g_build_filename(install_path, "share", "gkrellm2", "themes", NULL); theme_dir = g_build_filename(install_path, "share", "gkrellm2", "themes", NULL);
g_free(install_path);
}
if (theme_dir)
{
add_themes_to_list(theme_dir, FALSE); add_themes_to_list(theme_dir, FALSE);
g_free(theme_dir); g_free(theme_dir);
theme_dir = NULL; g_free(install_path);
} }
#endif #endif