[PATCH 5 of 6] Resolver: fixed ctx leak in an ngx_resolve_addr() error path
Maxim Dounin
mdounin at mdounin.ru
Tue Dec 1 03:58:38 UTC 2026
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1796094137 -10800
# Tue Dec 01 06:02:17 2026 +0300
# Node ID 3573ebe02a32fba540980d66cf7e62be8a17d16b
# Parent 4f0609931e7ee2d3deb23b6a77ca25e3c421d13c
Resolver: fixed ctx leak in an ngx_resolve_addr() error path.
The ngx_resolve_addr() function is expected to free ctx when returning
errors, yet it failed to do so in one of the code paths in case of
memory allocation errors in ngx_resolver_set_timeout(). The fix is to
properly free ctx, much like other code paths do.
diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c
--- a/src/core/ngx_resolver.c
+++ b/src/core/ngx_resolver.c
@@ -969,6 +969,7 @@ ngx_resolve_addr(ngx_resolver_ctx_t *ctx
if (rn->waiting) {
if (ngx_resolver_set_timeout(r, ctx) != NGX_OK) {
+ ngx_resolver_free(r, ctx);
return NGX_ERROR;
}
More information about the nginx-devel
mailing list