Hello!
I believe this will fix a memory leak in src/search.c. But please double-check!
At lines 1417-1422 the search_text is allocated: if (enc != NULL && g_utf8_validate(utf8_search_text, utf8_text_len, NULL)) { search_text = g_convert(utf8_search_text, utf8_text_len, enc, "UTF-8", NULL, NULL, NULL); } if (search_text == NULL) search_text = g_strdup(utf8_search_text);
The only usage of search_text between the lines 1417-1456 is: argv_prefix[i++] = g_strdup(search_text);
At line 1456 there is this code: if (argv == NULL) /* no files */ { g_strfreev(argv); return FALSE; }
I assume that a "g_free(search_text);" is needed before the return.
Best regards, Daniel
Daniel Marjamäki wrote:
I believe this will fix a memory leak in src/search.c. But please double-check!
I've been running with this patch since the day it was posted.
Looks good to me.
Erik
Hi,
On Thu, 5 Aug 2010 22:14:15 +0200 Daniel Marjamäki daniel.marjamaki@gmail.com wrote:
I believe this will fix a memory leak in src/search.c. But please double-check!
At lines 1417-1422 the search_text is allocated: if (enc != NULL && g_utf8_validate(utf8_search_text, utf8_text_len, NULL)) { search_text = g_convert(utf8_search_text, utf8_text_len, enc, "UTF-8", NULL, NULL, NULL); } if (search_text == NULL) search_text = g_strdup(utf8_search_text);
The only usage of search_text between the lines 1417-1456 is: argv_prefix[i++] = g_strdup(search_text);
At line 1456 there is this code: if (argv == NULL) /* no files */ { g_strfreev(argv); return FALSE; }
I assume that a "g_free(search_text);" is needed before the return.
I've just committed a patch based on your findings with svn r5145.
However, maybe we should revisit the function as it appears to me at the moment that search_text could be replaced completely by using utf8_search_text.
Cheers, Frank
On Thu, 12 Aug 2010 07:51:35 +0200 Frank Lanitz frank@frank.uvena.de wrote:
However, maybe we should revisit the function as it appears to me at the moment that search_text could be replaced completely by using utf8_search_text.
We sometimes want search_text to be a different encoding than UTF-8 - see the line:
search_text = g_convert(utf8_search_text, utf8_text_len, enc, "UTF-8", NULL, NULL, NULL);
So I think it's fine as it is.
Regards, Nick
On Thu, 12 Aug 2010 18:03:28 +0100, Nick Treleaven nick.treleaven@btinternet.com wrote:
On Thu, 12 Aug 2010 07:51:35 +0200 Frank Lanitz frank@frank.uvena.de wrote:
However, maybe we should revisit the function as it appears to me at the moment that search_text could be replaced completely by using utf8_search_text.
We sometimes want search_text to be a different encoding than UTF-8 - see the line:
search_text = g_convert(utf8_search_text, utf8_text_len, enc, "UTF-8", NULL, NULL, NULL);
So I think it's fine as it is.
Ahh... Missed http://git.geany.org/geany/tree/src/search.c#n1419 Good, that I did ask before just botching around ;)
Cheers, Frank