(load_panelize): replace while() by for() and fix potential memory leak.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2013-08-07 16:54:57 +04:00
parent bb142bf47f
commit 13c8f5213b

View File

@ -565,17 +565,14 @@ external_panelize (void)
void void
load_panelize (void) load_panelize (void)
{ {
gchar **profile_keys, **keys; char **keys;
gsize len; gsize len;
GIConv conv;
conv = str_crt_conv_from ("UTF-8"); keys = mc_config_get_keys (mc_main_config, panelize_section, &len);
profile_keys = keys = mc_config_get_keys (mc_main_config, panelize_section, &len);
add2panelize (g_strdup (_("Other command")), g_strdup ("")); add2panelize (g_strdup (_("Other command")), g_strdup (""));
if (!profile_keys || *profile_keys == NULL) if (keys == NULL || *keys == NULL)
{ {
add2panelize (g_strdup (_("Modified git files")), g_strdup ("git ls-files --modified")); add2panelize (g_strdup (_("Modified git files")), g_strdup ("git ls-files --modified"));
add2panelize (g_strdup (_("Find rejects after patching")), add2panelize (g_strdup (_("Find rejects after patching")),
@ -585,10 +582,15 @@ load_panelize (void)
add2panelize (g_strdup (_("Find SUID and SGID programs")), add2panelize (g_strdup (_("Find SUID and SGID programs")),
g_strdup g_strdup
("find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print")); ("find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print"));
return;
} }
else
{
GIConv conv;
char **profile_keys;
while (*profile_keys) conv = str_crt_conv_from ("UTF-8");
for (profile_keys = keys; *profile_keys != NULL; profile_keys++)
{ {
GString *buffer; GString *buffer;
@ -602,12 +604,14 @@ load_panelize (void)
} }
add2panelize (g_string_free (buffer, FALSE), add2panelize (g_string_free (buffer, FALSE),
mc_config_get_string (mc_main_config, panelize_section, *profile_keys, "")); mc_config_get_string (mc_main_config, panelize_section, *profile_keys,
profile_keys++; ""));
}
str_close_conv (conv);
} }
g_strfreev (keys); g_strfreev (keys);
str_close_conv (conv);
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */