Fixed potential memory leak.
Patch by Vincent Untz <vuntz@gnome.org>. Closes #566611. svn path=/branches/gnome-2-24/; revision=2788
This commit is contained in:
@@ -129,29 +129,29 @@ get_sys_path(glibtop* server, const char *device, char **stat_path, const char *
|
|||||||
|
|
||||||
static void linux_2_6_0(glibtop *server, glibtop_fsusage *buf, const char *path)
|
static void linux_2_6_0(glibtop *server, glibtop_fsusage *buf, const char *path)
|
||||||
{
|
{
|
||||||
char *filename;
|
char *filename = NULL;
|
||||||
const char *format;
|
const char *format;
|
||||||
int ret;
|
int ret;
|
||||||
char buffer[BUFSIZ];
|
char buffer[BUFSIZ];
|
||||||
char device[64];
|
char device[64];
|
||||||
|
|
||||||
if (!get_device(server, path, device, sizeof device))
|
if (!get_device(server, path, device, sizeof device))
|
||||||
return;
|
goto out;
|
||||||
|
|
||||||
get_sys_path(server, device, &filename, &format);
|
get_sys_path(server, device, &filename, &format);
|
||||||
|
|
||||||
ret = try_file_to_buffer(buffer, sizeof buffer, filename);
|
ret = try_file_to_buffer(buffer, sizeof buffer, filename);
|
||||||
|
|
||||||
if(ret < 0) return;
|
if (ret < 0) goto out;
|
||||||
|
|
||||||
if (sscanf(buffer, format, &buf->read, &buf->write) != 2) {
|
if (sscanf(buffer, format, &buf->read, &buf->write) != 2) {
|
||||||
glibtop_warn_io_r(server, "Could not parse %s", filename);
|
glibtop_warn_io_r(server, "Could not parse %s", filename);
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(filename);
|
|
||||||
|
|
||||||
buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
|
buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
|
||||||
|
out:
|
||||||
|
g_free(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user