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:
Benoît Dejean
2004-07-07 20:20:17 +00:00
parent 47b0db5ca9
commit c30e6a0dd2
2 changed files with 10 additions and 4 deletions

View File

@@ -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>
* sysinfo.c: (init_sysinfo): Removed useless memset.

View File

@@ -42,11 +42,11 @@ char *
glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf,
pid_t pid, unsigned max_len)
{
char filename[48];
char filename[48]; /* magiv */
char *args;
gsize length;
GError *error;
GError *error = NULL;
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);
if(!g_file_get_contents(filename, &args, &length, &error)) {
g_error_free(error);
buf->size = 0;
return NULL;
}
if(max_len && max_len < length) {
args = g_realloc(args, max_len+1);
args[max_len] = '\0';
args = g_realloc(args, max_len);
args[max_len - 1] = '\0';
length = max_len;
}