From 85212ddebea487445ab5fb1d281eeff4ed07824c Mon Sep 17 00:00:00 2001 From: jsing Date: Sat, 13 Aug 2016 13:15:53 +0000 Subject: [PATCH] Avoid leaking memory if tls_config_set_alpn() is called multiple times (this was in the original commit, but got reverted in the recommit). --- lib/libtls/tls_config.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/libtls/tls_config.c b/lib/libtls/tls_config.c index cd2a04cdd6b..0d52704aa81 100644 --- a/lib/libtls/tls_config.c +++ b/lib/libtls/tls_config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_config.c,v 1.26 2016/08/13 13:05:51 jsing Exp $ */ +/* $OpenBSD: tls_config.c,v 1.27 2016/08/13 13:15:53 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -311,6 +311,10 @@ tls_config_parse_alpn(struct tls_config *config, const char *alpn, char *s = NULL; char *p, *q; + free(*alpn_data); + *alpn_data = NULL; + *alpn_len = 0; + if ((buf_len = strlen(alpn) + 1) > 65535) { tls_config_set_errorx(config, "alpn too large"); goto err; @@ -355,9 +359,6 @@ tls_config_parse_alpn(struct tls_config *config, const char *alpn, free(buf); free(s); - *alpn_data = NULL; - *alpn_len = 0; - return (-1); } -- 2.20.1