Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fTicK-0004pN-Jh for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Jun 2018 06:53:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fTicJ-0006kk-7A for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Jun 2018 06:53:51 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fTicI-0006kZ-Ss for pgsql-hackers@lists.postgresql.org; Fri, 15 Jun 2018 06:53:51 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fTicF-0000Vz-4m for pgsql-hackers@postgresql.org; Fri, 15 Jun 2018 06:53:49 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 018D940EEE for ; Fri, 15 Jun 2018 08:53:42 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id b2cpD9E4iZhq for ; Fri, 15 Jun 2018 08:53:41 +0200 (CEST) From: Antonin Houska To: pgsql-hackers@postgresql.org Subject: Memory leaks in BufFileOpenShared() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 15 Jun 2018 08:54:52 +0200 Message-ID: <11329.1529045692@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 cha= r *name) BufFile * BufFileOpenShared(SharedFileSet *fileset, const char *name) { - BufFile *file =3D (BufFile *) palloc(sizeof(BufFile)); + BufFile *file; char segment_name[MAXPGPATH]; Size capacity =3D 16; - File *files =3D palloc(sizeof(File) * capacity); + File *files; int nfiles =3D 0; =20 file =3D (BufFile *) palloc(sizeof(BufFile)); --=20 Antonin Houska Cybertec Sch=C3=B6nig & Sch=C3=B6nig GmbH Gr=C3=B6hrm=C3=BChlgasse 26, A-2700 Wiener Neustadt Web: https://www.cybertec-postgresql.com