=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/telnet/telnet.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- src/usr.bin/telnet/telnet.c 1999/07/23 15:04:48 1.7 +++ src/usr.bin/telnet/telnet.c 1999/12/30 16:58:22 1.8 @@ -1,4 +1,4 @@ -/* $OpenBSD: telnet.c,v 1.7 1999/07/23 15:04:48 aaron Exp $ */ +/* $OpenBSD: telnet.c,v 1.8 1999/12/30 16:58:22 itojun Exp $ */ /* $NetBSD: telnet.c,v 1.7 1996/02/28 21:04:15 thorpej Exp $ */ /* @@ -1509,10 +1509,15 @@ void env_opt_start() { - if (opt_reply) - opt_reply = (unsigned char *)realloc(opt_reply, OPT_REPLY_SIZE); - else - opt_reply = (unsigned char *)malloc(OPT_REPLY_SIZE); + unsigned char *p; + + if (opt_reply) { + p = (unsigned char *)realloc(opt_reply, OPT_REPLY_SIZE); + if (p == NULL) + free(opt_reply); + } else + p = (unsigned char *)malloc(OPT_REPLY_SIZE); + opt_reply = p; if (opt_reply == NULL) { /*@*/ printf("env_opt_start: malloc()/realloc() failed!!!\n"); opt_reply = opt_replyp = opt_replyend = NULL; @@ -1560,9 +1565,13 @@ strlen((char *)ep) + 6 > opt_replyend) { register int len; + unsigned char *p; opt_replyend += OPT_REPLY_SIZE; len = opt_replyend - opt_reply; - opt_reply = (unsigned char *)realloc(opt_reply, len); + p = (unsigned char *)realloc(opt_reply, len); + if (p == NULL) + free(opt_reply); + opt_reply = p; if (opt_reply == NULL) { /*@*/ printf("env_opt_add: realloc() failed!!!\n"); opt_reply = opt_replyp = opt_replyend = NULL;