summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuis G.F <luisgf@gmail.com>2014-03-12 12:40:30 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2014-03-12 18:33:46 +0100
commitfe5385198f94ad85c0cb783e96e55561a51e5915 (patch)
tree9bc9d75229fc0d947b61a0d2ebdd52ba5e17297c /src
parentf1eafdae18909847d062474a04c03159b104eabb (diff)
downloadgnutls-fe5385198f94ad85c0cb783e96e55561a51e5915.tar.gz
serv.c Fix memory leak for *crtinfo pointer. The reference is lost if an allocation error occured.
Signed-off-by: Luis G.F <luisgf@luisgf.es>
Diffstat (limited to 'src')
-rw-r--r--src/serv.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/serv.c b/src/serv.c
index 5b446493d3..06b0d119eb 100644
--- a/src/serv.c
+++ b/src/serv.c
@@ -425,7 +425,7 @@ static char *peer_print_info(gnutls_session_t session, int *ret_length,
char *http_buffer;
gnutls_kx_algorithm_t kx_alg;
size_t len = 20 * 1024 + strlen(header);
- char *crtinfo = NULL;
+ char *crtinfo, *crtinfo_old = NULL;
size_t ncrtinfo = 0;
if (verbose == 0) {
@@ -463,13 +463,16 @@ static char *peer_print_info(gnutls_session_t session, int *ret_length,
GNUTLS_CRT_PRINT_FULL,
&info) == 0) {
const char *post = "</PRE><P><PRE>";
-
+
+ crtinfo_old = crtinfo;
crtinfo =
realloc(crtinfo,
ncrtinfo + info.size +
strlen(post) + 1);
- if (crtinfo == NULL)
+ if (crtinfo == NULL) {
+ free(crtinfo_old);
return NULL;
+ }
memcpy(crtinfo + ncrtinfo, info.data,
info.size);
ncrtinfo += info.size;