Content-Length: 318935 | pFad | http://github.com/postgrespro/postgres/commit/d46ad72f464beafa6d92d60d214412374559e280

40 Create memory context for tokenization after opening top-level file i… · postgrespro/postgres@d46ad72 · GitHub
Skip to content

Commit d46ad72

Browse files
committed
Create memory context for tokenization after opening top-level file in hba.c
The memory context was created before attempting to open the first HBA or ident file, which would cause it to leak. This had no consequences for the system views for HBA and ident files, but this would cause memory leaks in the postmaster on reload if the initial HBA and/or ident files are missing, which is a valid behavior while the backend is running. Oversight in efc9816. Author: Ted Yu Discussion: https://postgr.es/m/CALte62xH6ivgiKKzPRJgfekPZC6FKLB3xbnf3=tZmc_gKj78dw@mail.gmail.com
1 parent d5566fb commit d46ad72

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/backend/libpq/hba.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -601,22 +601,6 @@ open_auth_file(const char *filename, int elevel, int depth,
601601
return NULL;
602602
}
603603

604-
/*
605-
* When opening the top-level file, create the memory context used for the
606-
* tokenization. This will be closed with this file when coming back to
607-
* this level of cleanup.
608-
*/
609-
if (depth == 0)
610-
{
611-
/*
612-
* A context may be present, but assume that it has been eliminated
613-
* already.
614-
*/
615-
tokenize_context = AllocSetContextCreate(CurrentMemoryContext,
616-
"tokenize_context",
617-
ALLOCSET_START_SMALL_SIZES);
618-
}
619-
620604
file = AllocateFile(filename, "r");
621605
if (file == NULL)
622606
{
@@ -634,6 +618,22 @@ open_auth_file(const char *filename, int elevel, int depth,
634618
return NULL;
635619
}
636620

621+
/*
622+
* When opening the top-level file, create the memory context used for the
623+
* tokenization. This will be closed with this file when coming back to
624+
* this level of cleanup.
625+
*/
626+
if (depth == 0)
627+
{
628+
/*
629+
* A context may be present, but assume that it has been eliminated
630+
* already.
631+
*/
632+
tokenize_context = AllocSetContextCreate(CurrentMemoryContext,
633+
"tokenize_context",
634+
ALLOCSET_START_SMALL_SIZES);
635+
}
636+
637637
return file;
638638
}
639639

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/d46ad72f464beafa6d92d60d214412374559e280

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy