mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-23 22:06:21 +00:00
Cleanup and mem leak fix
Improve usage of `gchar` and `char` by setting them correctly Increase usage of `auto_gchar` and `auto_char` Fix 2 mem leaks (rosterwin.c, avatar.c)
This commit is contained in:
@@ -317,7 +317,7 @@ _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const use
|
||||
}
|
||||
}
|
||||
|
||||
auto_gchar gchar* from = str_replace(from_attr, "@", "_at_");
|
||||
auto_char char* from = str_replace(from_attr, "@", "_at_");
|
||||
g_string_append(filename, from);
|
||||
|
||||
avatar_metadata* data = (avatar_metadata*)userdata;
|
||||
@@ -345,18 +345,16 @@ _avatar_request_item_result_handler(xmpp_stanza_t* const stanza, void* const use
|
||||
|
||||
// if we shall open it
|
||||
if (g_hash_table_contains(shall_open, from_attr)) {
|
||||
gchar* cmdtemplate = prefs_get_string(PREF_AVATAR_CMD);
|
||||
auto_gchar gchar* cmdtemplate = prefs_get_string(PREF_AVATAR_CMD);
|
||||
|
||||
if (cmdtemplate == NULL) {
|
||||
cons_show_error("No default `avatar open` command found in executables preferences.");
|
||||
} else {
|
||||
gchar** argv = format_call_external_argv(cmdtemplate, NULL, filename->str);
|
||||
auto_gcharv gchar** argv = format_call_external_argv(cmdtemplate, NULL, filename->str);
|
||||
|
||||
if (!call_external(argv)) {
|
||||
cons_show_error("Unable to display avatar: check the logs for more information.");
|
||||
}
|
||||
|
||||
g_strfreev(argv);
|
||||
}
|
||||
|
||||
g_hash_table_remove(shall_open, from_attr);
|
||||
|
||||
@@ -1322,12 +1322,10 @@ _vcard_photo_result(xmpp_stanza_t* const stanza, void* userdata)
|
||||
g_string_free(filename, TRUE);
|
||||
}
|
||||
}
|
||||
gchar* from1 = str_replace(from, "@", "_at_");
|
||||
gchar* from2 = str_replace(from1, "/", "_slash_");
|
||||
g_free(from1);
|
||||
auto_char char* from1 = str_replace(from, "@", "_at_");
|
||||
auto_char char* from2 = str_replace(from1, "/", "_slash_");
|
||||
|
||||
g_string_append(filename, from2);
|
||||
g_free(from2);
|
||||
} else {
|
||||
filename = g_string_new(data->filename);
|
||||
}
|
||||
@@ -1357,17 +1355,15 @@ _vcard_photo_result(xmpp_stanza_t* const stanza, void* userdata)
|
||||
gchar** argv;
|
||||
gint argc;
|
||||
|
||||
gchar* cmdtemplate = prefs_get_string(PREF_VCARD_PHOTO_CMD);
|
||||
auto_gchar gchar* cmdtemplate = prefs_get_string(PREF_VCARD_PHOTO_CMD);
|
||||
|
||||
// this makes it work with filenames that contain spaces
|
||||
g_string_prepend(filename, "\"");
|
||||
g_string_append(filename, "\"");
|
||||
gchar* cmd = str_replace(cmdtemplate, "%p", filename->str);
|
||||
g_free(cmdtemplate);
|
||||
auto_char char* cmd = str_replace(cmdtemplate, "%p", filename->str);
|
||||
|
||||
if (g_shell_parse_argv(cmd, &argc, &argv, &err) == FALSE) {
|
||||
cons_show_error("Failed to parse command template");
|
||||
g_free(cmd);
|
||||
} else {
|
||||
if (!call_external(argv)) {
|
||||
cons_show_error("Unable to execute command");
|
||||
|
||||
Reference in New Issue
Block a user