Re: [Geany-devel] A few fixes for codenav, geanygdb, geanyinsertnum and geanylatex
Le 26/02/2011 13:41, Frank Lanitz a écrit : On Wed, 23 Feb 2011 19:32:07 +0100 Colomban Wendling lists@herbesfolles.org wrote: [./geanylatex/src/templates.c:47]: (error) Memory leak: template I also attach here the fixes I propose for them, if you're interested. I'm afraid I don't see why this should be a memory leak. Can you please be so kind and go into more details to prevent similar cases in future? It's a possible memory leak because you exit the function conditionally after the allocation, but don't free it in this branch: TemplateEntry *template = g_new0(TemplateEntry, 1); gchar *tmp = NULL; /* Return if its not a searched file */ if (g_str_has_suffix(file,.gtl) == FALSE) /* Leak here! */ return; /* ... */ g_free(template); So the easiest fix is to allocate the memory after the conditional exit since it isn't used before. Regards, Colomban ___ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Re: [Geany-devel] A few fixes for codenav, geanygdb, geanyinsertnum and geanylatex
Le 26/02/2011 14:50, Frank Lanitz a écrit : On Sat, 26 Feb 2011 14:21:11 +0100 Colomban Wendling lists@herbesfolles.org wrote: Le 26/02/2011 13:41, Frank Lanitz a écrit : On Wed, 23 Feb 2011 19:32:07 +0100 Colomban Wendling lists@herbesfolles.org wrote: [./geanylatex/src/templates.c:47]: (error) Memory leak: template I also attach here the fixes I propose for them, if you're interested. I'm afraid I don't see why this should be a memory leak. Can you please be so kind and go into more details to prevent similar cases in future? It's a possible memory leak because you exit the function conditionally after the allocation, but don't free it in this branch: TemplateEntry *template = g_new0(TemplateEntry, 1); gchar *tmp = NULL; /* Return if its not a searched file */ if (g_str_has_suffix(file,.gtl) == FALSE) /* Leak here! */ return; /* ... */ g_free(template); So the easiest fix is to allocate the memory after the conditional exit since it isn't used before. True. Ah... and now I see. You were not doing a patch against trunk of geanylatex. Its fixed already inside http://yaturl.net/2c80 Oops, I didn't though main development don't go in geany-plugins/geanylatex, sorry :/ However, I suggest you to do the allocation after the conditional exit rather than before and freeing it if taking the branch, because alloc/free is far from being a no-op ;) Cheers, Colomban ___ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Re: [Geany-devel] A few fixes for codenav, geanygdb, geanyinsertnum and geanylatex
On Sat, 26 Feb 2011 16:45:13 +0100 Colomban Wendling lists@herbesfolles.org wrote: Le 26/02/2011 14:50, Frank Lanitz a écrit : On Sat, 26 Feb 2011 14:21:11 +0100 Colomban Wendling lists@herbesfolles.org wrote: Le 26/02/2011 13:41, Frank Lanitz a écrit : On Wed, 23 Feb 2011 19:32:07 +0100 Colomban Wendling lists@herbesfolles.org wrote: [./geanylatex/src/templates.c:47]: (error) Memory leak: template I also attach here the fixes I propose for them, if you're interested. I'm afraid I don't see why this should be a memory leak. Can you please be so kind and go into more details to prevent similar cases in future? It's a possible memory leak because you exit the function conditionally after the allocation, but don't free it in this branch: TemplateEntry *template = g_new0(TemplateEntry, 1); gchar *tmp = NULL; /* Return if its not a searched file */ if (g_str_has_suffix(file,.gtl) == FALSE) /* Leak here! */ return; /* ... */ g_free(template); So the easiest fix is to allocate the memory after the conditional exit since it isn't used before. True. Ah... and now I see. You were not doing a patch against trunk of geanylatex. Its fixed already inside http://yaturl.net/2c80 Oops, I didn't though main development don't go in geany-plugins/geanylatex, sorry :/ However, I suggest you to do the allocation after the conditional exit rather than before and freeing it if taking the branch, because alloc/free is far from being a no-op ;) Yep, you are right. Will do this ;) Cheers, Frank -- http://frank.uvena.de/en/ pgpTvlJRMaBhJ.pgp Description: PGP signature ___ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
[Geany-devel] A few fixes for codenav, geanygdb, geanyinsertnum and geanylatex
Hi plugin maintainers, In context of the ideas on increasing quality of plugins thread, I tested a few code checker on geany-plugins trunk, and cppcheck found a few little problems: [./codenav/src/switch_head_impl.c:144]: (error) Memory leak: lang [./geanygdb/src/gdb-io-frame.c:186]: (error) Possible null pointer dereference: lv [./geanyinsertnum/src/insertnum.c:156]: (error) Memory leak: line_pos [./geanylatex/src/templates.c:47]: (error) Memory leak: template I also attach here the fixes I propose for them, if you're interested. Regards, Colomban diff --git a/geany-plugins/codenav/src/switch_head_impl.c b/geany-plugins/codenav/src/switch_head_impl.c index fc062ec..a407043 100644 --- a/geany-plugins/codenav/src/switch_head_impl.c +++ b/geany-plugins/codenav/src/switch_head_impl.c @@ -131,7 +131,7 @@ switch_head_impl_cleanup() static void fill_default_languages_list() { - Language* lang = g_malloc0(sizeof(Language)); + Language* lang = NULL; languages = NULL; diff --git a/geany-plugins/geanygdb/src/gdb-io-frame.c b/geany-plugins/geanygdb/src/gdb-io-frame.c index aa4bd90..6ac7a70 100644 --- a/geany-plugins/geanygdb/src/gdb-io-frame.c +++ b/geany-plugins/geanygdb/src/gdb-io-frame.c @@ -182,8 +182,8 @@ var_created(gint seq, gchar ** list, gchar * resp) lv-type = g_strdup(type ? type : int); lv-value = fmt_val(value); lv-numchild = g_strdup(numchild ? numchild : 0); + delete_var(lv-name); } - delete_var(lv-name); } if (h) g_hash_table_destroy(h); diff --git a/geany-plugins/geanyinsertnum/src/insertnum.c b/geany-plugins/geanyinsertnum/src/insertnum.c index ae66ccd..67a833e 100644 --- a/geany-plugins/geanyinsertnum/src/insertnum.c +++ b/geany-plugins/geanyinsertnum/src/insertnum.c @@ -153,6 +153,7 @@ static void insert_numbers(gboolean *cancel) if (*cancel) { ui_progress_bar_stop(); +g_free (line_pos); return; } } diff --git a/geany-plugins/geanylatex/src/templates.c b/geany-plugins/geanylatex/src/templates.c index ea3d1f6..fcc44ba 100644 --- a/geany-plugins/geanylatex/src/templates.c +++ b/geany-plugins/geanylatex/src/templates.c @@ -39,13 +39,14 @@ GString *glatex_get_template_from_file(gchar *filepath) static void glatex_init_cutom_template_item(gchar *file, GPtrArray *array) { - TemplateEntry *template = g_new0(TemplateEntry, 1); + TemplateEntry *template = NULL; gchar *tmp = NULL; /* Return if its not a searched file */ if (g_str_has_suffix(file,.gtl) == FALSE) return; + template = g_new0(TemplateEntry, 1); template-filepath = g_strdup(file); tmp = g_path_get_basename(file); ___ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Re: [Geany-devel] A few fixes for codenav, geanygdb, geanyinsertnum and geanylatex
Am Mittwoch, den 23.02.2011, 19:32 +0100 schrieb Colomban Wendling: [./geanygdb/src/gdb-io-frame.c:186]: (error) Possible null pointer dereference: lv Applied. Thanks. :) -- Dominic Hopf dma...@googlemail.com http://dominichopf.de/ Key Fingerprint: A7DF C4FC 07AE 4DDC 5CA0 BD93 AAB0 6019 CA7D 868D signature.asc Description: This is a digitally signed message part ___ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
Re: [Geany-devel] A few fixes for codenav, geanygdb, geanyinsertnum and geanylatex
On Wed, 23 Feb 2011 19:32:07 +0100 Colomban Wendling lists@herbesfolles.org wrote: [./geanyinsertnum/src/insertnum.c:156]: (error) Memory leak: line_pos Thanks. It was never freed actually... -- E-gards: Jimmy ___ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel