Skip to content

Commit

Permalink
Merge pull request #252 from b4n/geanysendmail/dialog-crash
Browse files Browse the repository at this point in the history
GeanySendMail: Fix crashes in the address dialog
  • Loading branch information
frlan committed Jun 25, 2015
2 parents 4b11123 + 3ba7bcc commit 00ecbcc
Showing 1 changed file with 6 additions and 7 deletions.
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

0 comments on commit 00ecbcc

Please sign in to comment.