Fixed. error is now correctly set to NULL before is's used. Fixed max_len
* procargs.c: (glibtop_get_proc_args_s): Fixed. error is now correctly set to NULL before is's used. Fixed max_len behaviour.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
2004-07-07 Benoît Dejean <tazforever@dlfp.org>
|
||||||
|
|
||||||
|
* procargs.c: (glibtop_get_proc_args_s): Fixed. error is now correctly
|
||||||
|
set to NULL before is's used. Fixed max_len behaviour.
|
||||||
|
|
||||||
2004-07-03 Benoît Dejean <tazforever@dlfp.org>
|
2004-07-03 Benoît Dejean <tazforever@dlfp.org>
|
||||||
|
|
||||||
* sysinfo.c: (init_sysinfo): Removed useless memset.
|
* sysinfo.c: (init_sysinfo): Removed useless memset.
|
||||||
|
@@ -42,11 +42,11 @@ char *
|
|||||||
glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
||||||
pid_t pid, unsigned max_len)
|
pid_t pid, unsigned max_len)
|
||||||
{
|
{
|
||||||
char filename[48];
|
char filename[48]; /* magiv */
|
||||||
|
|
||||||
char *args;
|
char *args;
|
||||||
gsize length;
|
gsize length;
|
||||||
GError *error;
|
GError *error = NULL;
|
||||||
|
|
||||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_ARGS, 0);
|
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_ARGS, 0);
|
||||||
|
|
||||||
@@ -55,13 +55,14 @@ glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
|
|||||||
sprintf (filename, "/proc/%d/cmdline", pid);
|
sprintf (filename, "/proc/%d/cmdline", pid);
|
||||||
|
|
||||||
if(!g_file_get_contents(filename, &args, &length, &error)) {
|
if(!g_file_get_contents(filename, &args, &length, &error)) {
|
||||||
|
g_error_free(error);
|
||||||
buf->size = 0;
|
buf->size = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(max_len && max_len < length) {
|
if(max_len && max_len < length) {
|
||||||
args = g_realloc(args, max_len+1);
|
args = g_realloc(args, max_len);
|
||||||
args[max_len] = '\0';
|
args[max_len - 1] = '\0';
|
||||||
length = max_len;
|
length = max_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user