Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ttuvo-001ueP-1h for pgsql-bugs@arkaria.postgresql.org; Sun, 16 Mar 2025 20:50:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ttuvl-000zo1-QY for pgsql-bugs@arkaria.postgresql.org; Sun, 16 Mar 2025 20:49:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ttuvl-000zns-HZ for pgsql-bugs@lists.postgresql.org; Sun, 16 Mar 2025 20:49:57 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ttuvj-003CXu-14 for pgsql-bugs@lists.postgresql.org; Sun, 16 Mar 2025 20:49:56 +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 52GKnrf13791437; Sun, 16 Mar 2025 16:49:53 -0400 From: Tom Lane To: Daniel Gustafsson cc: pm91.arapov@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18845: DEREF_OF_NULL.RET guc_malloc possibly returns NULL In-reply-to: <1FD7ACAC-0EBD-47D8-98B6-CC8285C571FF@yesql.se> References: <18845-582c6e10247377ec@postgresql.org> <3051193.1741961099@sss.pgh.pa.us> <3487876.1742059377@sss.pgh.pa.us> <1FD7ACAC-0EBD-47D8-98B6-CC8285C571FF@yesql.se> Comments: In-reply-to Daniel Gustafsson message dated "Sun, 16 Mar 2025 20:59:15 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3791435.1742158193.1@sss.pgh.pa.us> Date: Sun, 16 Mar 2025 16:49:53 -0400 Message-ID: <3791436.1742158193@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Daniel Gustafsson writes: > Those are all good points, I initially didn't think we should touch the > PGC_POSTMASTER cases but you are correct that avoiding back copy pastes to > happen is a Good Thing. The attached has all these fixes added. I think your fix in check_debug_io_direct is wrong: - *extra = guc_malloc(ERROR, sizeof(int)); + *extra = guc_malloc(LOG, sizeof(int)); + if (!*extra) + { + pfree(rawstring); + list_free(elemlist); + return false; + } It looks to me like rawstring and elemlist were already freed, so "return false" ought to be sufficient. Also, in init_custom_variable maybe it'd be worth a comment, along the lines of - gen = (struct config_generic *) guc_malloc(ERROR, sz); + /* As above, OOM is fatal */ + gen = (struct config_generic *) guc_malloc(FATAL, sz); Otherwise LGTM. regards, tom lane