]> granicus.if.org Git - procps-ng/commitdiff
top: fix two potential 'alternate display mode' abends
authorJim Warner <james.warner@comcast.net>
Mon, 31 May 2021 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Wed, 2 Jun 2021 10:16:32 +0000 (20:16 +1000)
This commit will address potential abends upon leaving
the windows help or color mapping screens and invoking
alternate display mode ('A').  It only happens if that
current window was changed with multiple 'a'/'w' keys.

So now, rather than leaving a trail of negative values
in the 'begtask' field, compliments of that win_select
function, we'll remove the mkVIZrow1 macro. Henceforth
it will be issued just once per user interaction. Thus
a promise of 'Curwin' only being impacted is restored.

[ my thanks to Vladimir Chren for reporting this bug ]

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/210
https://gitlab.com/procps-ng/procps/-/merge_requests/135

Discovered by:Vladimir Chren <vladimir.chren@gmail.com>
Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c

index 3e22139a1ef926404fd884d4197db7d6ad117a94..5905d6fe4662b159f6645b52cf13ac674e80b262 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -4060,7 +4060,6 @@ static WIN_t *win_select (int ch) {
          break;
    }
    Curwin = w;
-   mkVIZrow1(Curwin);
    return Curwin;
 } // end: win_select
 
@@ -4736,6 +4735,7 @@ static void keys_global (int ch) {
       case '?':
       case 'h':
          help_view();
+         mkVIZrow1(Curwin);
          break;
       case 'B':
          TOGw(w, View_NOBOLD);
@@ -4763,6 +4763,7 @@ static void keys_global (int ch) {
          break;
       case 'g':
          win_select(0);
+         mkVIZrow1(Curwin);
          break;
       case 'H':
          Thread_mode = !Thread_mode;
@@ -4842,6 +4843,7 @@ static void keys_global (int ch) {
          break;
       case 'Z':
          wins_colors();
+         mkVIZrow1(Curwin);
          break;
       case '0':
          Rc.zero_suppress = !Rc.zero_suppress;
@@ -5161,7 +5163,10 @@ static void keys_window (int ch) {
          break;
       case 'a':
       case 'w':
-         if (ALTCHKw) win_select(ch);
+         if (ALTCHKw) {
+            win_select(ch);
+            mkVIZrow1(Curwin);
+         }
          break;
       case 'G':
          if (ALTCHKw) {