Browse files

Fix a memory leak in tm_get_current_function()

  • Loading branch information...
1 parent 2e72599 commit 17396aaa999a6a2ce91f190d7aac56492c945712 @b4n b4n committed Sep 17, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 tagmanager/src/tm_workspace.c
View
10 tagmanager/src/tm_workspace.c
@@ -736,27 +736,27 @@ const TMTag *
tm_get_current_function (GPtrArray * file_tags, const gulong line)
{
GPtrArray *const local = tm_tags_extract (file_tags, tm_tag_function_t);
+ TMTag *function_tag = NULL;
if (local && local->len)
{
guint i;
- TMTag *tag, *function_tag = NULL;
gulong function_line = 0;
glong delta;
for (i = 0; (i < local->len); ++i)
{
- tag = TM_TAG (local->pdata[i]);
+ TMTag *tag = TM_TAG (local->pdata[i]);
delta = line - tag->atts.entry.line;
if (delta >= 0 && (gulong)delta < line - function_line)
{
function_tag = tag;
function_line = tag->atts.entry.line;
}
}
- g_ptr_array_free (local, TRUE);
- return function_tag;
}
- return NULL;
+ if (local)
+ g_ptr_array_free (local, TRUE);
+ return function_tag;
}

0 comments on commit 17396aa

Please sign in to comment.