summaryrefslogtreecommitdiffstats
path: root/lib/libssl/src
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2014-07-10 21:57:40 +0000
committermiod <miod@openbsd.org>2014-07-10 21:57:40 +0000
commit1ec1808972a901f9f50826ce5c8695f259f2fdf1 (patch)
treeafd42be119559917842fda8a0798205190db6fc6 /lib/libssl/src
parentUpon realloc() failure, free() the original pointer and remove the stupid (diff)
downloadwireguard-openbsd-1ec1808972a901f9f50826ce5c8695f259f2fdf1.tar.xz
wireguard-openbsd-1ec1808972a901f9f50826ce5c8695f259f2fdf1.zip
Simplify realloc() usage; ok tedu@
Diffstat (limited to 'lib/libssl/src')
-rw-r--r--lib/libssl/src/crypto/bio/b_sock.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/lib/libssl/src/crypto/bio/b_sock.c b/lib/libssl/src/crypto/bio/b_sock.c
index 32ac3b06649..bbae2a31b92 100644
--- a/lib/libssl/src/crypto/bio/b_sock.c
+++ b/lib/libssl/src/crypto/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;