Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeanySendMail: Fix crashes in the address dialog #252

Merged
merged 2 commits into from
Jun 25, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions geanysendmail/src/geanysendmail.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ send_as_attachment(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer g
gchar *command = NULL;
GError *error = NULL;
GString *cmd_str = NULL;
GKeyFile *config = g_key_file_new();
gchar *config_dir = g_path_get_dirname(config_file);
gchar *data;

doc = document_get_current();
Expand All @@ -95,13 +93,16 @@ send_as_attachment(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer g
cmd_str = g_string_new(mailer);
if ((use_address_dialog == TRUE) && (g_strrstr(mailer, "%r") != NULL))
{
GKeyFile *config = NULL;
gchar *config_dir = NULL;
gchar *input = dialogs_show_input(_("Recipient's Address"),
GTK_WINDOW(geany->main_widgets->window),
_("Enter the recipient's e-mail address:"),
address);

if (input)
{
config = g_key_file_new();
g_key_file_load_from_file(config, config_file, G_KEY_FILE_NONE, NULL);

g_free(address);
Expand All @@ -116,6 +117,7 @@ send_as_attachment(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer g
return;
}

config_dir = g_path_get_dirname(config_file);
if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) &&
utils_mkdir(config_dir, TRUE) != 0)
{
Expand All @@ -128,9 +130,9 @@ send_as_attachment(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer g
data = g_key_file_to_data(config, NULL, NULL);
utils_write_file(config_file, data);
g_free(data);
g_key_file_free(config);
g_free(config_dir);
}
g_key_file_free(config);
g_free(config_dir);
}

if (! utils_string_replace_all(cmd_str, "%f", locale_filename))
Expand All @@ -142,7 +144,6 @@ send_as_attachment(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer g
if (! utils_string_replace_all(cmd_str, "%r", address))
ui_set_statusbar(FALSE,
_("Recipient address placeholder not found. The executed command might have failed."));
g_free(address);
}
else
{
Expand Down Expand Up @@ -172,8 +173,6 @@ send_as_attachment(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer g
{
ui_set_statusbar(FALSE, _("File has to be saved before sending."));
}

g_key_file_free(config);
}

static void key_send_as_attachment(G_GNUC_UNUSED guint key_id)
Expand Down