aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author7 <notzed@helixcode.com>2000-05-07 13:04:31 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-05-07 13:04:31 +0800
commit97505d53504d42a41b4dd61ba99cb784e665d6c4 (patch)
tree46812d6024db2698dbbece6663be03d54ad9f75a
parentcca467781c7ced39d93dc7ee03197717fd3e563b (diff)
downloadgsoc2013-evolution-97505d53504d42a41b4dd61ba99cb784e665d6c4.tar
gsoc2013-evolution-97505d53504d42a41b4dd61ba99cb784e665d6c4.tar.gz
gsoc2013-evolution-97505d53504d42a41b4dd61ba99cb784e665d6c4.tar.bz2
gsoc2013-evolution-97505d53504d42a41b4dd61ba99cb784e665d6c4.tar.lz
gsoc2013-evolution-97505d53504d42a41b4dd61ba99cb784e665d6c4.tar.xz
gsoc2013-evolution-97505d53504d42a41b4dd61ba99cb784e665d6c4.tar.zst
gsoc2013-evolution-97505d53504d42a41b4dd61ba99cb784e665d6c4.zip
Also close the fd after we're done.
2000-05-07 <notzed@helixcode.com> * file.c (ibex_open): Also close the fd after we're done. svn path=/trunk/; revision=2859
-rw-r--r--libibex/ChangeLog4
-rw-r--r--libibex/file.c9
2 files changed, 11 insertions, 2 deletions
diff --git a/libibex/ChangeLog b/libibex/ChangeLog
index abd1914e84..016416574f 100644
--- a/libibex/ChangeLog
+++ b/libibex/ChangeLog
@@ -1,4 +1,6 @@
-2000-05-06 NotZed <NotZed@HelixCode.com>
+2000-05-07 <notzed@helixcode.com>
+
+ * file.c (ibex_open): Also close the fd after we're done.
* find.c (ibex_contains_name): New function to find out if a file
is indexed.
diff --git a/libibex/file.c b/libibex/file.c
index 5c292e198f..462fbec3d4 100644
--- a/libibex/file.c
+++ b/libibex/file.c
@@ -114,6 +114,7 @@ ibex_open (char *file, int flags, int mode)
if (f == NULL) {
if (errno == 0)
errno = ENOMEM;
+ close(fd);
return NULL;
}
@@ -124,12 +125,16 @@ ibex_open (char *file, int flags, int mode)
ib->words = g_hash_table_new (g_str_hash, g_str_equal);
ib->oldfiles = g_ptr_array_new ();
- if (!f)
+ if (!f) {
+ close(fd);
return ib;
+ }
/* Check version. If its empty, then we have just created it */
if (fread (vbuf, 1, sizeof (vbuf), f) != sizeof (vbuf)) {
if (feof (f)) {
+ fclose(f);
+ close(fd);
return ib;
}
}
@@ -177,11 +182,13 @@ ibex_open (char *file, int flags, int mode)
g_free (ibfs);
fclose (f);
+ close(fd);
return ib;
errout:
fclose (f);
+ close(fd);
g_tree_traverse (ib->files, free_file, G_IN_ORDER, NULL);
g_tree_destroy (ib->files);
g_hash_table_foreach (ib->words, free_word, NULL);