Re: patch: stream leak fix
- From: Frederic Crozat <fcrozat mandrakesoft com>
- To: Alexander Larsson <alexl redhat com>
- Cc: gnome-vfs-list gnome org
- Subject: Re: patch: stream leak fix
- Date: 05 Dec 2002 10:58:04 +0100
Le jeu 05/12/2002 à 10:49, Alexander Larsson a écrit :
> On 4 Dec 2002, Frederic Crozat wrote:
>
> > Hi,
> >
> > while trying to fix a monitoring problem for gnome-vfs mime user dir, I
> > found what I think is a stream leak in both write_back_keys_user_file
> > and write_back_mime_user_file..
> >
> > Can I commit the attached patch (with changelog entry, of course..) ?
>
> I think a better solution is to make ensure_user_directory_exist() return
> a gboolean and closedir() itself, since no users actually use the DIR *.
Agreed.. But my first though was to not modify internal calls :))
Better patch attached..
--
Frederic Crozat <fcrozat mandrakesoft com>
MandrakeSoft
--- gnome-vfs-2.1.3.1/libgnomevfs/gnome-vfs-mime-info.c.mimeinfo 2002-08-05 15:08:27.000000000 +0200
+++ gnome-vfs-2.1.3.1/libgnomevfs/gnome-vfs-mime-info.c 2002-12-05 10:55:46.000000000 +0100
@@ -1515,10 +1515,11 @@
}
-static DIR *
+static gboolean
ensure_user_directory_exist (void)
{
DIR *dir;
+ gboolean retval;
if (stat (user_mime_dir.dirname, &user_mime_dir.s) != -1)
user_mime_dir.valid = TRUE;
@@ -1541,7 +1542,9 @@
}
}
- return dir;
+ retval = (dir != NULL);
+ closedir (dir);
+ return retval;
}
@@ -1567,12 +1570,10 @@
static GnomeVFSResult
write_back_mime_user_file (void)
{
- DIR *dir;
FILE *file;
char *filename;
- dir = ensure_user_directory_exist ();
- if (dir == NULL) {
+ if (!ensure_user_directory_exist ()) {
return gnome_vfs_result_from_errno ();
}
@@ -1623,12 +1624,10 @@
static GnomeVFSResult
write_back_keys_user_file (void)
{
- DIR *dir;
FILE *file;
char *filename;
- dir = ensure_user_directory_exist ();
- if (dir == NULL) {
+ if (!ensure_user_directory_exist ()) {
return gnome_vfs_result_from_errno ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]