diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2014-07-10 21:57:41 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2014-07-10 21:57:41 +0000 |
commit | 5df135a6640c434df537226f2ae8b1dea2d02a5e (patch) | |
tree | 7629451ff4421b407f8baefe1a73cd861b727b30 /lib/libcrypto | |
parent | 2c520f8ed58b2a47e7b06b09ba94c2ee5acdbd5f (diff) |
Simplify realloc() usage; ok tedu@
Diffstat (limited to 'lib/libcrypto')
-rw-r--r-- | lib/libcrypto/bio/b_sock.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/lib/libcrypto/bio/b_sock.c b/lib/libcrypto/bio/b_sock.c index 32ac3b06649..bbae2a31b92 100644 --- a/lib/libcrypto/bio/b_sock.c +++ b/lib/libcrypto/bio/b_sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: b_sock.c,v 1.52 2014/07/10 13:58:22 jsing Exp $ */ +/* $OpenBSD: b_sock.c,v 1.53 2014/07/10 21:57:40 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -417,26 +417,17 @@ BIO_accept(int sock, char **addr) break; nl = strlen(h) + strlen(s) + 2; p = *addr; - if (p) { + if (p) *p = '\0'; - if (!(tmp = realloc(p, nl))) { - close(ret); - ret = -1; - free(p); - *addr = NULL; - BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE); - goto end; - } - p = tmp; - } else { - p = malloc(nl); - } - if (p == NULL) { + if (!(tmp = realloc(p, nl))) { close(ret); ret = -1; + free(p); + *addr = NULL; BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE); goto end; } + p = tmp; *addr = p; snprintf(*addr, nl, "%s:%s", h, s); goto end; |