open-auth-file-cleanup.patch
application/octet-stream
Filename: open-auth-file-cleanup.patch
Type: application/octet-stream
Part: 0
Message:
cleanup in open_auth_file
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/libpq/hba.c | 8 | 3 |
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index 432fbeeb1c..0995a61e25 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -603,7 +603,7 @@ open_auth_file(const char *filename, int elevel, int depth,
/*
* When opening the top-level file, create the memory context used for the
- * tokenization. This will be closed with this file when coming back to
+ * tokenization. This will be deleted with this file when coming back to
* this level of cleanup.
*/
if (depth == 0)
@@ -613,8 +613,8 @@ open_auth_file(const char *filename, int elevel, int depth,
* already.
*/
tokenize_context = AllocSetContextCreate(CurrentMemoryContext,
- "tokenize_context",
- ALLOCSET_START_SMALL_SIZES);
+ "tokenize_context",
+ ALLOCSET_START_SMALL_SIZES);
}
file = AllocateFile(filename, "r");
@@ -622,6 +622,11 @@ open_auth_file(const char *filename, int elevel, int depth,
{
int save_errno = errno;
+ if (depth == 0)
+ {
+ MemoryContextDelete(tokenize_context);
+ tokenize_context = NULL;
+ }
ereport(elevel,
(errcode_for_file_access(),
errmsg("could not open file \"%s\": %m",