diff --git a/core/hooks.c b/core/hooks.c index a9112a9d..0e6c5365 100644 --- a/core/hooks.c +++ b/core/hooks.c @@ -738,7 +738,8 @@ void uwsgi_hooks_setns_run(struct uwsgi_string_list *l, pid_t pid, uid_t uid, gi uwsgi_error("uwsgi_hooks_setns_run()/setns()"); exit(1); } - + close(fd); + free(procfile); } if (setenv("UWSGI_VASSAL_PID", pidstr, 1)) { diff --git a/core/subscription.c b/core/subscription.c index a3765ef0..6bd03f28 100644 --- a/core/subscription.c +++ b/core/subscription.c @@ -931,6 +931,7 @@ void uwsgi_subscribe2(char *arg, uint8_t cmd) { char *s2_proto = NULL; char *s2_algo = NULL; char *s2_backup = NULL; + struct uwsgi_buffer *ub = NULL; if (uwsgi_kvlist_parse(arg, strlen(arg), ',', '=', "server", &s2_server, @@ -998,7 +999,7 @@ void uwsgi_subscribe2(char *arg, uint8_t cmd) { s2_addr = uwsgi_str(uwsgi.sockets->name); } - struct uwsgi_buffer *ub = uwsgi_buffer_new(uwsgi.page_size); + ub = uwsgi_buffer_new(uwsgi.page_size); if (!ub) goto end; // leave space for the header ub->pos = 4; @@ -1058,9 +1059,10 @@ void uwsgi_subscribe2(char *arg, uint8_t cmd) { send_subscription(-1, s2_server, ub->buf, ub->pos); - uwsgi_buffer_destroy(ub); - end: + if (ub) + uwsgi_buffer_destroy(ub); + if (s2_server) free(s2_server); if (s2_key) diff --git a/plugins/router_memcached/router_memcached.c b/plugins/router_memcached/router_memcached.c index 9b0d2142..b4bbb97d 100644 --- a/plugins/router_memcached/router_memcached.c +++ b/plugins/router_memcached/router_memcached.c @@ -312,6 +312,7 @@ static int uwsgi_router_memcached(struct uwsgi_route *ur, char *args) { if (!urmc->key || !urmc->addr) { uwsgi_log("invalid route syntax: you need to specify a memcached address and key pattern\n"); + free(urmc); return -1; } @@ -346,6 +347,7 @@ static int uwsgi_router_memcached_store(struct uwsgi_route *ur, char *args) { if (!urmc->key || !urmc->addr) { uwsgi_log("invalid memcachedstore route syntax: you need to specify an address and a key\n"); + free(urmc); return -1; } diff --git a/plugins/router_redis/router_redis.c b/plugins/router_redis/router_redis.c index 52890893..fdf009d6 100644 --- a/plugins/router_redis/router_redis.c +++ b/plugins/router_redis/router_redis.c @@ -310,6 +310,7 @@ static int uwsgi_router_redis(struct uwsgi_route *ur, char *args) { if (!urrc->key || !urrc->addr) { uwsgi_log("invalid route syntax: you need to specify a redis address and key pattern\n"); + free(urrc); return -1; } @@ -344,6 +345,7 @@ static int uwsgi_router_redis_store(struct uwsgi_route *ur, char *args) { if (!urrc->key || !urrc->addr) { uwsgi_log("invalid redisstore route syntax: you need to specify an address and a key\n"); + free(urrc); return -1; } diff --git a/plugins/router_static/router_static.c b/plugins/router_static/router_static.c index 232b37e9..14c5d8e2 100644 --- a/plugins/router_static/router_static.c +++ b/plugins/router_static/router_static.c @@ -67,7 +67,10 @@ int uwsgi_routing_func_file(struct wsgi_request *wsgi_req, struct uwsgi_route *u // static file - don't update avg_rt after request wsgi_req->do_not_account_avg_rt = 1; - if (urfc->no_headers) goto send; + if (urfc->no_headers) { + uwsgi_buffer_destroy(ub_s); + goto send; + } if (uwsgi_response_prepare_headers(wsgi_req, ub_s->buf, ub_s->pos)) { uwsgi_buffer_destroy(ub_s); @@ -138,7 +141,10 @@ int uwsgi_routing_func_sendfile(struct wsgi_request *wsgi_req, struct uwsgi_rout // static file - don't update avg_rt after request wsgi_req->do_not_account_avg_rt = 1; - if (urfc->no_headers) goto send; + if (urfc->no_headers) { + uwsgi_buffer_destroy(ub_s); + goto send; + } if (uwsgi_response_prepare_headers(wsgi_req, ub_s->buf, ub_s->pos)) { uwsgi_buffer_destroy(ub_s); @@ -208,7 +214,10 @@ int uwsgi_routing_func_fastfile(struct wsgi_request *wsgi_req, struct uwsgi_rout // static file - don't update avg_rt after request wsgi_req->do_not_account_avg_rt = 1; - if (urfc->no_headers) goto send; + if (urfc->no_headers) { + uwsgi_buffer_destroy(ub_s); + goto send; + } if (uwsgi_response_prepare_headers(wsgi_req, ub_s->buf, ub_s->pos)) { uwsgi_buffer_destroy(ub_s); @@ -288,6 +297,7 @@ static int uwsgi_router_file(struct uwsgi_route *ur, char *args) { if (!urfc->filename) { uwsgi_log("you have to specifify a filename for the \"file\" router\n"); + free(urfc); return -1; } diff --git a/plugins/rpc/rpc_plugin.c b/plugins/rpc/rpc_plugin.c index b8a14a21..d3996678 100644 --- a/plugins/rpc/rpc_plugin.c +++ b/plugins/rpc/rpc_plugin.c @@ -455,7 +455,6 @@ static int uwsgi_routing_func_rpc_var(struct wsgi_request *wsgi_req, struct uwsg if (size == 0) goto end; if (!uwsgi_req_append(wsgi_req, ur->data4, ur->data4_len, response, size)) { - free(response); goto end; } ret = UWSGI_ROUTE_NEXT;