[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] It's not correct to call endwin() if initscr() fails, and it crashes
# 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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |