From b72cc7a509b05335b9f244d5b7a6a12a03c0bd7f Mon Sep 17 00:00:00 2001 From: miod <> Date: Thu, 10 Jul 2014 21:57:40 +0000 Subject: Simplify realloc() usage; ok tedu@ --- src/lib/libcrypto/bio/b_sock.c | 21 ++++++--------------- src/lib/libssl/src/crypto/bio/b_sock.c | 21 ++++++--------------- 2 files changed, 12 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c index 32ac3b0664..bbae2a31b9 100644 --- a/src/lib/libcrypto/bio/b_sock.c +++ b/src/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; diff --git a/src/lib/libssl/src/crypto/bio/b_sock.c b/src/lib/libssl/src/crypto/bio/b_sock.c index 32ac3b0664..bbae2a31b9 100644 --- a/src/lib/libssl/src/crypto/bio/b_sock.c +++ b/src/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; -- cgit v1.2.3-55-g6feb