WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] It's not correct to call endwin() if init

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] It's not correct to call endwin() if initscr() fails, and it crashes
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 17 Oct 2006 19:01:33 +0000
Delivery-date: Tue, 17 Oct 2006 12:02:57 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID c6a65f4815383209aeb7ba5007253b3b0fe8b84b
# Parent  9754c40fc6734bf27c698159dd61698996b6c52b
It's not correct to call endwin() if initscr() fails, and it crashes
older libcurses implementations.

Signed-off-by: John Levon <john.levon@xxxxxxx>
---
 tools/xenstat/xentop/xentop.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff -r 9754c40fc673 -r c6a65f481538 tools/xenstat/xentop/xentop.c
--- a/tools/xenstat/xentop/xentop.c     Tue Oct 17 18:35:13 2006 +0100
+++ b/tools/xenstat/xentop/xentop.c     Tue Oct 17 18:36:26 2006 +0100
@@ -187,6 +187,8 @@ int prompt_val_len = 0;
 int prompt_val_len = 0;
 void (*prompt_complete_func)(char *);
 
+static WINDOW *cwin;
+
 /*
  * Function definitions
  */
@@ -223,7 +225,7 @@ static void version(void)
 /* Clean up any open resources */
 static void cleanup(void)
 {
-       if(!isendwin())
+       if(cwin != NULL && !isendwin())
                endwin();
        if(prev_node != NULL)
                xenstat_free_node(prev_node);
@@ -236,7 +238,7 @@ static void cleanup(void)
 /* Display the given message and gracefully exit */
 static void fail(const char *str)
 {
-       if(!isendwin())
+       if(cwin != NULL && !isendwin())
                endwin();
        fprintf(stderr, str);
        exit(1);
@@ -1029,7 +1031,7 @@ int main(int argc, char **argv)
 
        if (!batch) {
                /* Begin curses stuff */
-               initscr();
+               cwin = initscr();
                start_color();
                cbreak();
                noecho();

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] It's not correct to call endwin() if initscr() fails, and it crashes, Xen patchbot-unstable <=