mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 15:06:14 +01:00
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.
This commit is contained in:
parent
6b931891bc
commit
f72f7be1d3
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
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>
|
2004-10-28 Ray Strode <rstrode@redhat.com>
|
||||||
|
|
||||||
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
|
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
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>
|
2004-10-28 Ray Strode <rstrode@redhat.com>
|
||||||
|
|
||||||
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
|
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
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>
|
2004-10-28 Ray Strode <rstrode@redhat.com>
|
||||||
|
|
||||||
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
|
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
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>
|
2004-10-28 Ray Strode <rstrode@redhat.com>
|
||||||
|
|
||||||
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
|
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
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>
|
2004-10-28 Ray Strode <rstrode@redhat.com>
|
||||||
|
|
||||||
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
|
* glib/gkeyfile.c: Don't use S_ISREG macro (#156728,
|
||||||
|
@ -277,9 +277,7 @@ find_file_in_data_dirs (const gchar *file,
|
|||||||
{
|
{
|
||||||
gchar **data_dirs, *data_dir, *path;
|
gchar **data_dirs, *data_dir, *path;
|
||||||
gint fd;
|
gint fd;
|
||||||
GError *file_error;
|
|
||||||
|
|
||||||
file_error = NULL;
|
|
||||||
path = NULL;
|
path = NULL;
|
||||||
fd = -1;
|
fd = -1;
|
||||||
|
|
||||||
@ -303,16 +301,11 @@ find_file_in_data_dirs (const gchar *file,
|
|||||||
|
|
||||||
fd = g_open (path, O_RDONLY, 0);
|
fd = g_open (path, O_RDONLY, 0);
|
||||||
|
|
||||||
if (output_file != NULL)
|
if (fd < 0)
|
||||||
*output_file = g_strdup (path);
|
{
|
||||||
|
|
||||||
g_free (path);
|
g_free (path);
|
||||||
|
path = NULL;
|
||||||
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"));
|
|
||||||
|
|
||||||
candidate_file = strchr (candidate_file, '-');
|
candidate_file = strchr (candidate_file, '-');
|
||||||
|
|
||||||
@ -336,19 +329,16 @@ find_file_in_data_dirs (const gchar *file,
|
|||||||
|
|
||||||
*dirs = data_dirs;
|
*dirs = data_dirs;
|
||||||
|
|
||||||
if (file_error)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
if (fd >= 0)
|
g_set_error (error, G_KEY_FILE_ERROR,
|
||||||
g_error_free (file_error);
|
G_KEY_FILE_ERROR_NOT_FOUND,
|
||||||
else
|
_("Valid key file could not be "
|
||||||
g_propagate_error (error, file_error);
|
"found in data dirs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output_file && fd < 0)
|
if (output_file != NULL && fd > 0)
|
||||||
{
|
*output_file = g_strdup (path);
|
||||||
g_free (*output_file);
|
|
||||||
*output_file = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
@ -364,8 +354,15 @@ g_key_file_load_from_fd (GKeyFile *key_file,
|
|||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
gchar read_buf[4096];
|
gchar read_buf[4096];
|
||||||
|
|
||||||
fstat (fd, &stat_buf);
|
if (fstat (fd, &stat_buf) < 0)
|
||||||
if ((stat_buf.st_mode & S_IFMT) == S_IFREG)
|
{
|
||||||
|
g_set_error (error, G_FILE_ERROR,
|
||||||
|
g_file_error_from_errno (errno),
|
||||||
|
"%s", g_strerror (errno));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((stat_buf.st_mode & S_IFMT) != S_IFREG)
|
||||||
{
|
{
|
||||||
g_set_error (error, G_KEY_FILE_ERROR,
|
g_set_error (error, G_KEY_FILE_ERROR,
|
||||||
G_KEY_FILE_ERROR_PARSE,
|
G_KEY_FILE_ERROR_PARSE,
|
||||||
@ -398,7 +395,7 @@ g_key_file_load_from_fd (GKeyFile *key_file,
|
|||||||
|
|
||||||
if (bytes_read < 0)
|
if (bytes_read < 0)
|
||||||
{
|
{
|
||||||
if (errno == EINTR)
|
if (errno == EINTR || errno == EAGAIN)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
g_set_error (error, G_FILE_ERROR,
|
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 ();
|
user_data_dir = g_get_user_data_dir ();
|
||||||
system_data_dirs = g_get_system_data_dirs ();
|
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;
|
i = 0;
|
||||||
all_data_dirs[i++] = g_strdup (user_data_dir);
|
all_data_dirs[i++] = g_strdup (user_data_dir);
|
||||||
|
Loading…
Reference in New Issue
Block a user