summaryrefslogtreecommitdiff
path: root/usr.bin/telnet/telnet.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/telnet/telnet.c')
-rw-r--r--usr.bin/telnet/telnet.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.bin/telnet/telnet.c b/usr.bin/telnet/telnet.c
index 65ee77f1e64..0a3b80b20d7 100644
--- a/usr.bin/telnet/telnet.c
+++ b/usr.bin/telnet/telnet.c
@@ -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 @@ unsigned char *opt_replyend;
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 @@ env_opt_add(ep)
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;