xfce4-taskmanager-0.2.1 patch
Xavier Otazu <[email protected]>
| Newsgroups | gmane.comp.desktop.xfce.goodies.devel |
|---|---|
| Organization | CVC |
| Message-ID | <[email protected]> |
Hi! The 0.2.1 version of xfce4-taslmanager produced a segmentation fault on my computer (Slackware 10.0 kernel 2.4.29). It also had some memory leaks that increased memory size at a 100Kb/s rate. I attach a patch that solves the segmentation error and memory leaks. cheers Xavier
xfce4-taskmanager-0.2.1_memleak.diff
(application/octet-stream, 1.4 KB)
--- xfce4-taskmanager-0.2.1/src/functions.c 2005-02-01 23:32:27.000000000 +0100
+++ xfce4-taskmanager-0.2.1_xop/src/functions.c 2005-04-03 23:51:54.000000000 +0200
@@ -62,6 +62,8 @@
g_strlcat(task_file_name,"/status", 256);
gchar buffer[256];
+ gchar label[256];
+ gchar **tmp, **tmp_uid;
gint line_count = 0;
struct task task;
struct passwd *passwdp;
@@ -70,7 +72,7 @@
{
while(fgets(buffer, 256, task_file) != NULL)
{
- if(line_count == 0)
+/* if(line_count == 0)
strcpy(task.name,g_strstrip(g_strsplit(buffer, ":", 2)[1]));
else if(line_count == 3)
strcpy(task.pid,g_strstrip(g_strsplit(buffer, ":", 2)[1]));
@@ -81,7 +83,23 @@
passwdp = getpwuid(atoi(g_strsplit(g_strstrip(g_strsplit(buffer, ":", 2)[1]), "\t", 2)[0]));
strcpy(task.uid, passwdp->pw_name);
}
-
+*/
+ tmp=g_strsplit(buffer, ":", 2);
+ strcpy(label,tmp[0]);
+ if(!strcmp(label,"Name"))
+ strcpy(task.name,g_strstrip(tmp[1]));
+ else if(!strcmp(label,"Pid"))
+ strcpy(task.pid,g_strstrip(tmp[1]));
+ else if(!strcmp(label,"PPid"))
+ strcpy(task.ppid,g_strstrip(tmp[1]));
+ else if(!strcmp(label,"Uid"))
+ {
+ tmp_uid=g_strsplit(g_strstrip(tmp[1]), "\t", 2);
+ passwdp = getpwuid(atoi(tmp_uid[0]));
+ strcpy(task.uid, passwdp->pw_name);
+ g_strfreev(tmp_uid);
+ }
+ g_strfreev(tmp);
line_count++;
}