summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2004-10-28 22:10:06 +0000
committerRay Strode <halfline@src.gnome.org>2004-10-28 22:10:06 +0000
commitf72f7be1d371ab4610f80609393a7c00c88670a1 (patch)
tree8f12985375a42fbc0f6aba133467180019ccedef
parent6b931891bc526616f124f97a2b4c815ab8f4032c (diff)
downloadglib-f72f7be1d371ab4610f80609393a7c00c88670a1.tar.gz
clean up a leak (#156652, Morten Welinder) (g_key_file_load_from_fd):
2004-10-28 Ray Strode <rstrode@redhat.com> * glib/gkeyfile.c (find_file_in_data_dirs): clean up a leak (#156652, Morten Welinder) (g_key_file_load_from_fd): propagate fstat() error conditions and retry read on EAGAIN (#156647, Morten Welinder). Return error if file is NOT regular, not if it is regular (bug introduced from last commited bug fix). (g_key_file_load_from_data_dirs): allocate enough space for the terminating NULL.
-rw-r--r--ChangeLog13
-rw-r--r--ChangeLog.pre-2-1013
-rw-r--r--ChangeLog.pre-2-1213
-rw-r--r--ChangeLog.pre-2-613
-rw-r--r--ChangeLog.pre-2-813
-rw-r--r--glib/gkeyfile.c49
6 files changed, 88 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 981f86ff5..c619dd9f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2004-10-28 Ray Strode <rstrode@redhat.com>
+ * glib/gkeyfile.c
+ (find_file_in_data_dirs): clean up a leak (#156652,
+ Morten Welinder)
+ (g_key_file_load_from_fd): propagate fstat() error
+ conditions and retry read on EAGAIN (#156647, Morten
+ Welinder). Return error if file is NOT regular, not if
+ it is regular (bug introduced from last commited bug
+ fix).
+ (g_key_file_load_from_data_dirs): allocate enough space
+ for the terminating NULL.
+
+2004-10-28 Ray Strode <rstrode@redhat.com>
+
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
Kazuki IWAMOTO)
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 981f86ff5..c619dd9f2 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,5 +1,18 @@
2004-10-28 Ray Strode <rstrode@redhat.com>
+ * glib/gkeyfile.c
+ (find_file_in_data_dirs): clean up a leak (#156652,
+ Morten Welinder)
+ (g_key_file_load_from_fd): propagate fstat() error
+ conditions and retry read on EAGAIN (#156647, Morten
+ Welinder). Return error if file is NOT regular, not if
+ it is regular (bug introduced from last commited bug
+ fix).
+ (g_key_file_load_from_data_dirs): allocate enough space
+ for the terminating NULL.
+
+2004-10-28 Ray Strode <rstrode@redhat.com>
+
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
Kazuki IWAMOTO)
diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12
index 981f86ff5..c619dd9f2 100644
--- a/ChangeLog.pre-2-12
+++ b/ChangeLog.pre-2-12
@@ -1,5 +1,18 @@
2004-10-28 Ray Strode <rstrode@redhat.com>
+ * glib/gkeyfile.c
+ (find_file_in_data_dirs): clean up a leak (#156652,
+ Morten Welinder)
+ (g_key_file_load_from_fd): propagate fstat() error
+ conditions and retry read on EAGAIN (#156647, Morten
+ Welinder). Return error if file is NOT regular, not if
+ it is regular (bug introduced from last commited bug
+ fix).
+ (g_key_file_load_from_data_dirs): allocate enough space
+ for the terminating NULL.
+
+2004-10-28 Ray Strode <rstrode@redhat.com>
+
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
Kazuki IWAMOTO)
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 981f86ff5..c619dd9f2 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,5 +1,18 @@
2004-10-28 Ray Strode <rstrode@redhat.com>
+ * glib/gkeyfile.c
+ (find_file_in_data_dirs): clean up a leak (#156652,
+ Morten Welinder)
+ (g_key_file_load_from_fd): propagate fstat() error
+ conditions and retry read on EAGAIN (#156647, Morten
+ Welinder). Return error if file is NOT regular, not if
+ it is regular (bug introduced from last commited bug
+ fix).
+ (g_key_file_load_from_data_dirs): allocate enough space
+ for the terminating NULL.
+
+2004-10-28 Ray Strode <rstrode@redhat.com>
+
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
Kazuki IWAMOTO)
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 981f86ff5..c619dd9f2 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,5 +1,18 @@
2004-10-28 Ray Strode <rstrode@redhat.com>
+ * glib/gkeyfile.c
+ (find_file_in_data_dirs): clean up a leak (#156652,
+ Morten Welinder)
+ (g_key_file_load_from_fd): propagate fstat() error
+ conditions and retry read on EAGAIN (#156647, Morten
+ Welinder). Return error if file is NOT regular, not if
+ it is regular (bug introduced from last commited bug
+ fix).
+ (g_key_file_load_from_data_dirs): allocate enough space
+ for the terminating NULL.
+
+2004-10-28 Ray Strode <rstrode@redhat.com>
+
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
Kazuki IWAMOTO)
diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c
index 9f18511a4..2084c6d77 100644
--- a/glib/gkeyfile.c
+++ b/glib/gkeyfile.c
@@ -277,9 +277,7 @@ find_file_in_data_dirs (const gchar *file,
{
gchar **data_dirs, *data_dir, *path;
gint fd;
- GError *file_error;
- file_error = NULL;
path = NULL;
fd = -1;
@@ -303,16 +301,11 @@ find_file_in_data_dirs (const gchar *file,
fd = g_open (path, O_RDONLY, 0);
- if (output_file != NULL)
- *output_file = g_strdup (path);
-
- g_free (path);
-
- if (fd < 0 && file_error == NULL)
- file_error = g_error_new (G_KEY_FILE_ERROR,
- G_KEY_FILE_ERROR_NOT_FOUND,
- _("Valid key file could not be "
- "found in data dirs"));
+ if (fd < 0)
+ {
+ g_free (path);
+ path = NULL;
+ }
candidate_file = strchr (candidate_file, '-');
@@ -336,19 +329,16 @@ find_file_in_data_dirs (const gchar *file,
*dirs = data_dirs;
- if (file_error)
+ if (fd < 0)
{
- if (fd >= 0)
- g_error_free (file_error);
- else
- g_propagate_error (error, file_error);
+ g_set_error (error, G_KEY_FILE_ERROR,
+ G_KEY_FILE_ERROR_NOT_FOUND,
+ _("Valid key file could not be "
+ "found in data dirs"));
}
- if (output_file && fd < 0)
- {
- g_free (*output_file);
- *output_file = NULL;
- }
+ if (output_file != NULL && fd > 0)
+ *output_file = g_strdup (path);
return fd;
}
@@ -363,9 +353,16 @@ g_key_file_load_from_fd (GKeyFile *key_file,
gsize bytes_read;
struct stat stat_buf;
gchar read_buf[4096];
+
+ if (fstat (fd, &stat_buf) < 0)
+ {
+ g_set_error (error, G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ "%s", g_strerror (errno));
+ return FALSE;
+ }
- fstat (fd, &stat_buf);
- if ((stat_buf.st_mode & S_IFMT) == S_IFREG)
+ if ((stat_buf.st_mode & S_IFMT) != S_IFREG)
{
g_set_error (error, G_KEY_FILE_ERROR,
G_KEY_FILE_ERROR_PARSE,
@@ -398,7 +395,7 @@ g_key_file_load_from_fd (GKeyFile *key_file,
if (bytes_read < 0)
{
- if (errno == EINTR)
+ if (errno == EINTR || errno == EAGAIN)
continue;
g_set_error (error, G_FILE_ERROR,
@@ -570,7 +567,7 @@ g_key_file_load_from_data_dirs (GKeyFile *key_file,
user_data_dir = g_get_user_data_dir ();
system_data_dirs = g_get_system_data_dirs ();
- all_data_dirs = g_new0 (gchar *, g_strv_length ((gchar **)system_data_dirs) + 1);
+ all_data_dirs = g_new0 (gchar *, g_strv_length ((gchar **)system_data_dirs) + 2);
i = 0;
all_data_dirs[i++] = g_strdup (user_data_dir);