From aa34beade1ceaba6db484fc0262765d6fa905351 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 27 Dec 2013 19:09:49 +0100 Subject: [PATCH] core/legion: fix memory leak Reported by coverity as CID #971022. --- core/legion.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/legion.c b/core/legion.c index 69f3db38..0c5a1575 100644 --- a/core/legion.c +++ b/core/legion.c @@ -737,6 +737,7 @@ void uwsgi_legion_add(struct uwsgi_legion *ul) { int uwsgi_legion_announce(struct uwsgi_legion *ul) { struct uwsgi_buffer *ub = uwsgi_buffer_new(4096); + unsigned char *encrypted = NULL; if (uwsgi_buffer_append_keyval(ub, "legion", 6, ul->legion, ul->legion_len)) goto err; @@ -769,7 +770,7 @@ int uwsgi_legion_announce(struct uwsgi_legion *ul) { goto err; } - unsigned char *encrypted = uwsgi_malloc(ub->pos + 4 + EVP_MAX_BLOCK_LENGTH); + encrypted = uwsgi_malloc(ub->pos + 4 + EVP_MAX_BLOCK_LENGTH); if (EVP_EncryptInit_ex(ul->encrypt_ctx, NULL, NULL, NULL, NULL) <= 0) { uwsgi_error("[uwsgi-legion] EVP_EncryptInit_ex()"); goto err; @@ -808,6 +809,7 @@ int uwsgi_legion_announce(struct uwsgi_legion *ul) { return 0; err: uwsgi_buffer_destroy(ub); + free(encrypted); return -1; }