GeniusPaste: Fixes some memory leaks #57

Merged
merged 2 commits into from Aug 6, 2012

Conversation

Projects
None yet
3 participants
Owner

b4n commented Jul 12, 2012

No description provided.

@Enrix835 Enrix835 commented on the diff Jul 16, 2012

geniuspaste/src/geniuspaste.c
@@ -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);
@Enrix835

Enrix835 Jul 16, 2012

Member

Umh there's no need to free temp_body here, isn't it?

@b4n

b4n Jul 16, 2012

Owner

Right, g_strstrip() doesn't allocate the memory but rather modifies the string in-place. So yeah, the memory must not be freed (or it'd be freed twice and boom). For the record, e05f1d6 introduced the improper free.

BTW, you could even remove the temp_body variable and simply call g_strstrip() on p_url, or straight in the g_strdup_printf() call;

Owner

frlan commented Jul 26, 2012

Do you want to review the PR again or shall I apply it?

frlan merged commit b23f60d into geany:master Aug 6, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment