Branch: refs/heads/master Author: Frank Lanitz frank@frank.uvena.de Committer: Frank Lanitz frank@frank.uvena.de Date: Mon, 06 Aug 2012 17:11:51 Commit: b23f60dfeac76d878698a39c9f7870f9562aaac5 https://github.com/geany/geany-plugins/commit/b23f60dfeac76d878698a39c9f7870...
Log Message: ----------- Merge pull request #57 from b4n/fixes/geniuspaste
GeniusPaste: Fixes some memory leaks
Modified Paths: -------------- geniuspaste/src/geniuspaste.c
Modified: geniuspaste/src/geniuspaste.c 30 files changed, 14 insertions(+), 16 deletions(-) =================================================================== @@ -183,7 +183,6 @@ static void paste(GeanyDocument * doc, const gchar * website) gchar *p_url; gchar *formdata = NULL; gchar *user_agent = NULL; - gchar *temp_body; gchar **tokens_array;
const gchar *langs_supported_codepad[] = @@ -297,16 +296,21 @@ static void paste(GeanyDocument * doc, const gchar * website)
}
+ g_free(f_content); + user_agent = g_strconcat(PLUGIN_NAME, " ", PLUGIN_VERSION, " / Geany ", GEANY_VERSION, NULL); session = soup_session_async_new_with_options(SOUP_SESSION_USER_AGENT, user_agent, NULL); g_free(user_agent);
soup_message_set_request(msg, "application/x-www-form-urlencoded", - SOUP_MEMORY_COPY, formdata, strlen(formdata)); + SOUP_MEMORY_TAKE, formdata, strlen(formdata));
status = soup_session_send_message(session, msg); p_url = g_strdup(msg->response_body->data);
+ g_object_unref(session); + g_object_unref(msg); + if(status == SOUP_STATUS_OK) {
@@ -317,17 +321,15 @@ static void paste(GeanyDocument * doc, const gchar * website)
if (website_selected == CODEPAD_ORG) { - temp_body = g_strdup(p_url); - tokens_array = g_strsplit(temp_body, "<a href="", 0); + tokens_array = g_strsplit(p_url, "<a href="", 0);
/* cuts the string when it finds the first occurrence of '/' * It shoud work even if codepad would change its url. */
- p_url = g_strdup(tokens_array[5]); + SETPTR(p_url, g_strdup(tokens_array[5])); occ_position = indexof(tokens_array[5], '"');
- g_free(temp_body); g_strfreev(tokens_array);
if(occ_position != -1) @@ -353,18 +355,16 @@ static void paste(GeanyDocument * doc, const gchar * website) * <response>xxxxx</response> * </result> */ - temp_body = g_strdup(p_url); - tokens_array = g_strsplit_set(temp_body, "<>", 0); + tokens_array = g_strsplit_set(p_url, "<>", 0);
- p_url = g_strdup_printf("http://%s/%s", websites[TINYPASTE_COM], tokens_array[6]); + SETPTR(p_url, g_strdup_printf("http://%s/%s", websites[TINYPASTE_COM], tokens_array[6]));
- g_free(temp_body); g_strfreev(tokens_array); }
else if(website_selected == DPASTE_DE) { - p_url = g_strndup(p_url + 1, strlen(p_url) - 2); + SETPTR(p_url, g_strndup(p_url + 1, strlen(p_url) - 2));
} else if(website_selected == SPRUNGE_US) @@ -377,8 +377,8 @@ static void paste(GeanyDocument * doc, const gchar * website) * e.g. sprunge.us/xxxx?c */ gchar *ft_tmp = g_ascii_strdown(f_type, -1); - temp_body = g_strstrip(p_url); - p_url = g_strdup_printf("%s?%s", temp_body, ft_tmp); + gchar *temp_body = g_strstrip(p_url); + SETPTR(p_url, g_strdup_printf("%s?%s", temp_body, ft_tmp)); g_free(temp_body); g_free(ft_tmp); } @@ -405,9 +405,7 @@ static void paste(GeanyDocument * doc, const gchar * website) "Error code: %d\n"), status); }
- g_free(f_content); g_free(p_url); - g_object_unref(session); }
static void item_activate(GtkMenuItem * menuitem, gpointer gdata) @@ -435,7 +433,7 @@ static void on_configure_response(GtkDialog * dialog, gint response, gpointer * { website_selected = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets.combo)); check_button_is_checked = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets.check_button)); - author_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.author_entry))); + SETPTR(author_name, g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.author_entry)))); save_settings(); } }
@@ Diff output truncated at 100000 characters. @@
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
plugins-commits@lists.geany.org