Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1beNYA-0008I1-4S for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Aug 2016 14:28:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1beNY9-0003Ww-EH for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Aug 2016 14:28:33 +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.84_2) (envelope-from ) id 1beNWl-000206-4u for pgsql-hackers@postgresql.org; Mon, 29 Aug 2016 14:27:07 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1beNWf-0003Jf-4O for pgsql-hackers@postgresql.org; Mon, 29 Aug 2016 14:27:05 +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 u7TEQjq4022564; Mon, 29 Aug 2016 10:26:45 -0400 From: Tom Lane To: Aleksander Alekseev cc: Michael Paquier , Heikki Linnakangas , PostgreSQL mailing lists Subject: Re: Missing checks when malloc returns NULL... In-reply-to: <20160829130513.GA8340@e733> References: <7978.1466516782@sss.pgh.pa.us> <20160829130513.GA8340@e733> Comments: In-reply-to Aleksander Alekseev message dated "Mon, 29 Aug 2016 16:05:14 +0300" Date: Mon, 29 Aug 2016 10:26:45 -0400 Message-ID: <22563.1472480805@sss.pgh.pa.us> X-Pg-Spam-Score: -3.4 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Aleksander Alekseev writes: >> if (prodesc->user_proname == NULL || prodesc->internal_proname == NULL) >> + { >> + free(prodesc); > I think that prodesc->user_proname and prodesc->internal_proname should > also be freed if they are not NULL's. Hmm, this is kind of putting lipstick on a pig, isn't it? That code is still prone to leakage further down, because it calls stuff like SearchSysCache which is entirely capable of throwing elog(ERROR). If we're going to touch compile_pltcl_function at all, I'd vote for (1) changing these malloc calls to MemoryContextAlloc(TopMemoryContext,... (2) putting the cleanup into a PG_CATCH block, and removing all the retail free() calls that are there now. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers