From 07ef790cf84f43bded6059ef578c078b6ec9ce3f Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Mon, 16 Jan 2023 14:25:11 +0100 Subject: [PATCH] Close fd on fdopen fail. Originally suggested by @rgacogne, but not included in the merge of #12374 somehow. --- pdns/recursordist/negcache.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/pdns/recursordist/negcache.cc b/pdns/recursordist/negcache.cc index b526909517..542e99acba 100644 --- a/pdns/recursordist/negcache.cc +++ b/pdns/recursordist/negcache.cc @@ -278,6 +278,7 @@ size_t NegCache::doDump(int fd, size_t maxCacheEntries) } auto fp = std::unique_ptr(fdopen(newfd, "w"), fclose); if (!fp) { + close(newfd); return 0; } fprintf(fp.get(), "; negcache dump follows\n;\n"); -- 2.47.2