From: Otto Moerbeek Date: Mon, 16 Jan 2023 13:20:37 +0000 (+0100) Subject: close newfs on fopen fail X-Git-Tag: rec-4.8.2~5^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c00eba0ed3d41d52dee7bc2e036dfa837613914;p=thirdparty%2Fpdns.git close newfs on fopen fail Co-authored-by: Remi Gacogne --- diff --git a/pdns/recursordist/negcache.cc b/pdns/recursordist/negcache.cc index 3097ec0042..cf3b76fe8f 100644 --- a/pdns/recursordist/negcache.cc +++ b/pdns/recursordist/negcache.cc @@ -274,6 +274,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");