trivial one-off memory leak in guc-file.l ParseConfigFile
Hi
fix a small memory leak in guc-file.l ParseConfigFile
AbsoluteConfigLocation() return a strdup string but it's never free or
referenced outside ParseConfigFile
Courtesy Valgrind and Noah Misch MEMPOOL work.
Regards
Didier
Attachments:
memory_leak_in_parse_config_file.patchapplication/octet-stream; name=memory_leak_in_parse_config_file.patchDownload
diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l
index b730a12..e94f53d 100644
--- a/src/backend/utils/misc/guc-file.l
+++ b/src/backend/utils/misc/guc-file.l
@@ -411,6 +411,7 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict,
{
bool OK = true;
FILE *fp;
+ char *abs_config_file;
/*
* Reject too-deep include nesting depth. This is just a safety check
@@ -426,8 +427,8 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict,
return false;
}
- config_file = AbsoluteConfigLocation(config_file,calling_file);
- fp = AllocateFile(config_file, "r");
+ abs_config_file = AbsoluteConfigLocation(config_file,calling_file);
+ fp = AllocateFile(abs_config_file, "r");
if (!fp)
{
if (strict)
@@ -435,19 +436,22 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict,
ereport(elevel,
(errcode_for_file_access(),
errmsg("could not open configuration file \"%s\": %m",
- config_file)));
+ abs_config_file)));
+ pfree(abs_config_file);
return false;
}
ereport(LOG,
(errmsg("skipping missing configuration file \"%s\"",
- config_file)));
+ abs_config_file)));
+ pfree(abs_config_file);
return OK;
- }
+ }
- OK = ParseConfigFp(fp, config_file, depth, elevel, head_p, tail_p);
+ OK = ParseConfigFp(fp, abs_config_file, depth, elevel, head_p, tail_p);
FreeFile(fp);
+ pfree(abs_config_file);
return OK;
}
On Sun, Sep 22, 2013 at 3:40 PM, didier <did447@gmail.com> wrote:
fix a small memory leak in guc-file.l ParseConfigFile
AbsoluteConfigLocation() return a strdup string but it's never free or
referenced outside ParseConfigFileCourtesy Valgrind and Noah Misch MEMPOOL work.
I'd like to look at this, but I haven't got time right now. Could you
add it to the next CommitFest so it doesn't get forgotten about?
https://commitfest.postgresql.org/action/commitfest_view/open
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 22.09.2013 22:40, didier wrote:
Hi
fix a small memory leak in guc-file.l ParseConfigFile
AbsoluteConfigLocation() return a strdup string but it's never free or
referenced outside ParseConfigFileCourtesy Valgrind and Noah Misch MEMPOOL work.
I spotted and fixed this some time ago while fixing another leak, see
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=138184adc5f7c60c184972e4d23f8cdb32aed77d.
I didn't realize you had already reported it back then.
So, I've marked this as committed in the commitfest app. But thanks for
the report anyway.
- Heikki
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers