summaryrefslogtreecommitdiff
blob: b160bcc301a9e16e86c5a4afbbff8e9abbc01328 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Under certain conditions, top's display can break.
This patch is by Curtis Doty, updated by Andreas Kling for 3.2.5.

To reproduce bug:
 - run top
 - turn on color mode ('z')
 - highlight sort column ('x')
 - move sort column all the way to the left ('<')
 - get drunk

procps e-mail: http://sourceforge.net/mailarchive/forum.php?thread_id=6042978&forum_id=12454
Redhat bug:    http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=140975
Gentoo bug:    http://bugs.gentoo.org/show_bug.cgi?id=80296

--- procps-3.2.5/top.c~	2005-01-26 06:15:18.000000000 +0100
+++ procps-3.2.5/top.c	2005-02-01 09:23:35.000000000 +0100
@@ -2952,12 +2952,10 @@
    for (x = 0; x < q->maxpflgs; x++) {
       char cbuf[ROWBUFSIZ], _z[ROWBUFSIZ];
       FLG_t       i = q->procflags[x];          // support for our field/column
-      const char *f = Fieldstab[i].fmts;        // macro AND sometimes the fmt
+      const char *f = Fieldstab[i].fmts + ((x==0) && !Rc.mode_altscr);
       unsigned    s = Fieldstab[i].scale;       // string must be altered !
       unsigned    w = Fieldstab[i].width;
 
-      int advance = (x==0) && !Rc.mode_altscr;
-
       switch (i) {
          case P_CMD:
          {  char tmp[ROWBUFSIZ];
@@ -3069,7 +3067,7 @@
 
         } /* end: switch 'procflag' */
 
-        rp = scat(rp, cbuf+advance);
+        rp = scat(rp, cbuf);
    } /* end: for 'maxpflgs' */
 
    PUFF(