Module Name: src
Committed By: christos
Date: Sat Dec 24 22:29:48 UTC 2011
Modified Files:
src/external/bsd/top/dist: screen.c
Log Message:
PR/45739: Moritz Wilhelmy: top(1) segfaults on WINCH with unknown terminal
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/top/dist/screen.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/top/dist/screen.c
diff -u src/external/bsd/top/dist/screen.c:1.3 src/external/bsd/top/dist/screen.c:1.4
--- src/external/bsd/top/dist/screen.c:1.3 Tue May 5 14:51:21 2009
+++ src/external/bsd/top/dist/screen.c Sat Dec 24 17:29:48 2011
@@ -167,7 +167,7 @@ void
screen_getsize()
{
-
+ char *go;
#ifdef TIOCGWINSZ
struct winsize ws;
@@ -204,7 +204,10 @@ screen_getsize()
#endif /* TIOCGSIZE */
#endif /* TIOCGWINSZ */
- (void) strcpy(lower_left, tgoto(tc_cursor_motion, 0, screen_length - 1));
+ if ((go = tgoto(tc_cursor_motion, 0, screen_length - 1)) != NULL)
+ (void) strcpy(lower_left, go);
+ else
+ lower_left[0] = '\0';
}
int
@@ -214,6 +217,7 @@ screen_readtermcap(int interactive)
char *bufptr;
char *PCptr;
char *term_name;
+ char *go;
int status;
/* set defaults in case we aren't smart */
@@ -314,7 +318,10 @@ screen_readtermcap(int interactive)
PC = (PCptr = tgetstr("pc", &bufptr)) ? *PCptr : 0;
/* set convenience strings */
- (void) strcpy(home, tgoto(tc_cursor_motion, 0, 0));
+ if ((go = tgoto(tc_cursor_motion, 0, 0)) != NULL)
+ (void) strcpy(home, go);
+ else
+ home[0] = '\0';
/* (lower_left is set in screen_getsize) */
/* get the actual screen size with an ioctl, if needed */
@@ -502,7 +509,9 @@ void
screen_move(int x, int y)
{
- tputs(tgoto(tc_cursor_motion, x, y), 1, putstdout);
+ char *go = tgoto(tc_cursor_motion, x, y);
+ if (go)
+ tputs(go, 1, putstdout);
}
void