summaryrefslogtreecommitdiff
path: root/glib
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-07-19 20:17:03 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-07-19 20:17:03 +0000
commit83c4b0988e15615609d771125968423ab1764139 (patch)
tree17bb82d019e0be50fa85d25b7b4aa411f20dc86f /glib
parent3fa620d4dfeb3440526682b4970bc9147b6665c9 (diff)
downloadglib-83c4b0988e15615609d771125968423ab1764139.tar.gz
Fix memory leak and dubious list manipulation. (Found by Ron Koerner,
Thu Jul 19 16:05:21 2001 Owen Taylor <otaylor@redhat.com> * glib/gcompletion.c (g_completion_complete): Fix memory leak and dubious list manipulation. (Found by Ron Koerner, #53408) * glib/gfileutils.c (get_contents_stdio): Call fclose() on FILE * on error. (#57057)
Diffstat (limited to 'glib')
-rw-r--r--glib/gcompletion.c16
-rw-r--r--glib/gfileutils.c1
2 files changed, 8 insertions, 9 deletions
diff --git a/glib/gcompletion.c b/glib/gcompletion.c
index 1e882dcaa..9a33ff5ca 100644
--- a/glib/gcompletion.c
+++ b/glib/gcompletion.c
@@ -182,16 +182,14 @@ g_completion_complete (GCompletion* cmp,
list = cmp->cache;
while (list)
{
+ GList *next = list->next;
+
if (cmp->strncmp_func (prefix,
- cmp->func ? cmp->func (list->data) : (gchar*) list->data,
- len))
- {
- list = g_list_remove_link (cmp->cache, list);
- if (list != cmp->cache)
- cmp->cache = list;
- }
- else
- list = list->next;
+ cmp->func ? cmp->func (list->data) : (gchar*) list->data,
+ len))
+ cmp->cache = g_list_delete_link (cmp->cache, list);
+
+ list = next;
}
done = TRUE;
}
diff --git a/glib/gfileutils.c b/glib/gfileutils.c
index 9936867ce..031cbde61 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -309,6 +309,7 @@ get_contents_stdio (const gchar *filename,
filename, strerror (errno));
g_string_free (str, TRUE);
+ fclose (f);
return FALSE;
}