summaryrefslogtreecommitdiff
path: root/lib/libcurses/lib_mvcur.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-11-29 05:01:24 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-11-29 05:01:24 +0000
commit16d31019ef8a4fda95fffc64ccdb8c772af08976 (patch)
tree4c9288e555d41692712cce4c652b7fc11d15ecab /lib/libcurses/lib_mvcur.c
parent1d94037a7d1c1367be4627f319db375db12389f8 (diff)
Check malloc() return vals.
Diffstat (limited to 'lib/libcurses/lib_mvcur.c')
-rw-r--r--lib/libcurses/lib_mvcur.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/libcurses/lib_mvcur.c b/lib/libcurses/lib_mvcur.c
index a03a17338c7..807b6c5eeeb 100644
--- a/lib/libcurses/lib_mvcur.c
+++ b/lib/libcurses/lib_mvcur.c
@@ -1196,6 +1196,8 @@ static int roll(int n)
int main(int argc, char *argv[])
{
+ char *p;
+
(void) strncpy(tname, getenv("TERM"), sizeof(tname) - 1);
tname[sizeof(tname) - 1] = '\0';
load_term();
@@ -1208,10 +1210,15 @@ int main(int argc, char *argv[])
* Undo the effects of our optimization hack, otherwise our interactive
* prompts don't flush properly.
*/
+ if ((p = malloc(BUFSIZ)) == NULL) {
+ fprintf(stderr, "Can't allocate memory\n");
+ exit(1);
+ }
+
#if HAVE_SETVBUF
- (void) setvbuf(SP->_ofp, malloc(BUFSIZ), _IOLBF, BUFSIZ);
+ (void) setvbuf(SP->_ofp, p, _IOLBF, BUFSIZ);
#elif HAVE_SETBUFFER
- (void) setbuffer(SP->_ofp, malloc(BUFSIZ), BUFSIZ);
+ (void) setbuffer(SP->_ofp, p, BUFSIZ);
#endif
#endif /* HAVE_SETVBUF || HAVE_SETBUFFER */
@@ -1442,7 +1449,7 @@ int main(int argc, char *argv[])
_nc_mvcur_wrap();
putchar('\n');
- return(0);
+ exit(0);
}
#endif /* MAIN */