Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gVKJN-0005LB-Fy for pgsql-bugs@arkaria.postgresql.org; Fri, 07 Dec 2018 17:53:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gVKJL-0003ne-4i for pgsql-bugs@arkaria.postgresql.org; Fri, 07 Dec 2018 17:53:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gVKJK-0003nX-RW for pgsql-bugs@lists.postgresql.org; Fri, 07 Dec 2018 17:53:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gVKJE-0006a5-AO for pgsql-bugs@lists.postgresql.org; Fri, 07 Dec 2018 17:53:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wB7HquMk015916; Fri, 7 Dec 2018 12:52:57 -0500 From: Tom Lane To: bianpan2016@163.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15541: Use after release in PQprint In-reply-to: <15541-c835d8b9a903f7ad@postgresql.org> References: <15541-c835d8b9a903f7ad@postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Fri, 07 Dec 2018 10:42:54 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <15914.1544205176.1@sss.pgh.pa.us> Date: Fri, 07 Dec 2018 12:52:56 -0500 Message-ID: <15915.1544205176@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?utf-8?q?PG_Bug_reporting_form?= writes: > The function PQprint releases the file hander fout via pclose or _pclose > when usePipe is true. After that, fout is used again to write message > "fputs("\n", fout);". Wow, that is ancient. It looks like commit edb519b14 of 27-Jul-1996 added the pipe close stanza in the wrong place, and nobody's noticed it since. That's probably not so surprising given the multiple conditions required to trigger it plus the fact that this whole function is, if not completely dead code, at least not used anywhere in the PG distribution. Still, we oughta fix it. Thanks for the report! regards, tom lane