From 470144f56e7e4a72fd21fe67c2ad840190717eff Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Tue, 13 Nov 2012 04:51:19 -0700 Subject: [PATCH] basic_msnt_auth: minor memory leaks Detected by Coverity scan (free). Issues: 740415, 740416 --- helpers/basic_auth/MSNT/confload.cc | 2 +- helpers/basic_auth/MSNT/usersfile.cc | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/helpers/basic_auth/MSNT/confload.cc b/helpers/basic_auth/MSNT/confload.cc index 4184a51cce..eebf3001fe 100644 --- a/helpers/basic_auth/MSNT/confload.cc +++ b/helpers/basic_auth/MSNT/confload.cc @@ -85,6 +85,7 @@ OpenConfigFile(void) Confbuf[2048] = '\0'; ProcessLine(Confbuf); } + fclose(ConfigFile); /* * Check that at least one server is being queried. Report error if not. @@ -95,7 +96,6 @@ OpenConfigFile(void) syslog(LOG_ERR, "OpenConfigFile: No servers set in %s. At least one is needed.", CONFIGFILE); return 1; } - fclose(ConfigFile); return 0; } diff --git a/helpers/basic_auth/MSNT/usersfile.cc b/helpers/basic_auth/MSNT/usersfile.cc index 81e8e3661c..64271d13cb 100644 --- a/helpers/basic_auth/MSNT/usersfile.cc +++ b/helpers/basic_auth/MSNT/usersfile.cc @@ -83,14 +83,17 @@ Read_usersfile(const char *path, usersfile * uf) * Clear the allowed user string. Return. */ if (fstat(fileno(fp), &FileBuf) < 0) { syslog(LOG_ERR, "%s: %s", path, strerror(errno)); + fclose(fp); return 1; } /* If it exists, save the modification time and size */ uf->LMT = FileBuf.st_mtime; /* Handle the special case of a zero length file */ - if (FileBuf.st_size == 0) + if (FileBuf.st_size == 0) { + fclose(fp); return 0; + } /* * Read the file into memory -- 2.47.3