| From: | Antonin Houska <ah(at)cybertec(dot)at> | 
|---|---|
| To: | pgsql-hackers(at)postgresql(dot)org | 
| Subject: | Memory leaks in BufFileOpenShared() | 
| Date: | 2018-06-15 06:54:52 | 
| Message-ID: | 11329.1529045692@localhost | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tatsuo Ishii | 2018-06-15 07:20:03 | Re: Memory leaks in BufFileOpenShared() | 
| Previous Message | Amit Langote | 2018-06-15 06:16:39 | Re: Remove mention in docs that foreign keys on partitioned tables are not supported |