]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Close fd on fdopen fail. 12419/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 16 Jan 2023 13:25:11 +0000 (14:25 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 16 Jan 2023 13:25:11 +0000 (14:25 +0100)
Originally suggested by @rgacogne, but not included in the merge of #12374
somehow.

pdns/recursordist/negcache.cc

index b52690951723648854644a10ab84247f33069236..542e99acba52ee24c83e3254a98ee0cf50a1a9a4 100644 (file)
@@ -278,6 +278,7 @@ size_t NegCache::doDump(int fd, size_t maxCacheEntries)
   }
   auto fp = std::unique_ptr<FILE, int (*)(FILE*)>(fdopen(newfd, "w"), fclose);
   if (!fp) {
+    close(newfd);
     return 0;
   }
   fprintf(fp.get(), "; negcache dump follows\n;\n");