Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o2PPU-00070X-0q for pgsql-hackers@arkaria.postgresql.org; Sat, 18 Jun 2022 03:46:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o2PPS-0003bi-FW for pgsql-hackers@arkaria.postgresql.org; Sat, 18 Jun 2022 03:46:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o2PPS-0003bY-6o for pgsql-hackers@lists.postgresql.org; Sat, 18 Jun 2022 03:46:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o2PPK-0000FB-Po for pgsql-hackers@postgresql.org; Sat, 18 Jun 2022 03:46:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 25I3jrg01477432; Fri, 17 Jun 2022 23:45:53 -0400 From: Tom Lane To: Michael Paquier cc: Peter Eisentraut , pgsql-hackers Subject: Re: libpq: Remove redundant null pointer checks before free() In-reply-to: References: <5333caf7-7667-bc58-0fd0-2e82eaf01967@enterprisedb.com> Comments: In-reply-to Michael Paquier message dated "Sat, 18 Jun 2022 12:17:03 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1477429.1655523953.1@sss.pgh.pa.us> Date: Fri, 17 Jun 2022 23:45:53 -0400 Message-ID: <1477430.1655523953@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Michael Paquier writes: > On Fri, Jun 17, 2022 at 09:03:23PM +0200, Peter Eisentraut wrote: >> I'm pretty sure PostgreSQL code already depends on this behavior anyway. >> The code just isn't consistent about it. > In the frontend, I'd like to think that you are right and that we have > already some places doing that. We do, indeed. > The backend is a different story, > like in GetMemoryChunkContext(). That should be easy enough to check > with some LD_PRELOAD wizardry, at least. Huh? The proposal is to accept the fact that free() tolerates NULL, and then maybe make pfree() tolerate it as well. I don't think that that needs to encompass any other functions. regards, tom lane