Memory leaks in BufFileOpenShared()
Antonin Houska <ah@cybertec.at>
From: Antonin Houska <ah@cybertec.at>
To: pgsql-hackers@postgresql.org
Date: 2018-06-15T06:54:52Z
Lists: pgsql-hackers
Memory is allocated twice for "file" and "files" variables. Possible fix:
diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c
index d8a18dd3dc..00f61748b3 100644
--- a/src/backend/storage/file/buffile.c
+++ b/src/backend/storage/file/buffile.c
@@ -277,10 +277,10 @@ BufFileCreateShared(SharedFileSet *fileset, const char *name)
BufFile *
BufFileOpenShared(SharedFileSet *fileset, const char *name)
{
- BufFile *file = (BufFile *) palloc(sizeof(BufFile));
+ BufFile *file;
char segment_name[MAXPGPATH];
Size capacity = 16;
- File *files = palloc(sizeof(File) * capacity);
+ File *files;
int nfiles = 0;
file = (BufFile *) palloc(sizeof(BufFile));
--
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26, A-2700 Wiener Neustadt
Web: https://www.cybertec-postgresql.com
Commits
-
Fix memory leak in BufFileCreateShared().
- 1cfdb1cb0e3f 11.0 landed
-
Fix memory leak.
- 969274d81301 11.0 landed
-
Add infrastructure for sharing temporary files between backends.
- dc6c4c9dc2a1 11.0 cited