From: Otto Moerbeek Date: Mon, 16 Jan 2023 13:25:11 +0000 (+0100) Subject: Close fd on fdopen fail. X-Git-Tag: dnsdist-1.8.0-rc1~113^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07ef790cf84f43bded6059ef578c078b6ec9ce3f;p=thirdparty%2Fpdns.git Close fd on fdopen fail. Originally suggested by @rgacogne, but not included in the merge of #12374 somehow. --- 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");