From 2b20fd1d36fef96549d319c866176e5deb1ea1a1 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Fri, 18 May 2012 22:25:31 +0000 Subject: [PATCH] Avoid a potential memory leak --- src/appclient.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/appclient.c b/src/appclient.c index 0c737c9..3dbc6f1 100644 --- a/src/appclient.c +++ b/src/appclient.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2011 Pierre Pronchery */ +/* Copyright (c) 2011-2012 Pierre Pronchery */ /* This file is part of DeforaOS System libApp */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -362,8 +362,13 @@ static int _new_connect(AppClient * appclient, char const * app) if((appclient->ssl = SSL_new(appclient->ssl_ctx)) == NULL || SSL_set_fd(appclient->ssl, appclient->fd) != 1) + { + if(appclient->ssl != NULL) + SSL_free(appclient->ssl); + appclient->ssl = NULL; return error_set_code(1, "%s", ERR_error_string( ERR_get_error(), NULL)); + } appclient->error = _callback_error_ssl; appclient->read = _callback_read_ssl; appclient->write = _callback_write_ssl;