pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: pm91.arapov@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18845: DEREF_OF_NULL.RET guc_malloc possibly returns NULL
Date: Sun, 16 Mar 2025 16:49:53 -0400
Message-ID: <3791436.1742158193@sss.pgh.pa.us> (raw)
In-Reply-To: <1FD7ACAC-0EBD-47D8-98B6-CC8285C571FF@yesql.se>
References: <18845-582c6e10247377ec@postgresql.org>
	<A664B6DF-7D34-4004-AC89-66B1517B3301@yesql.se>
	<3051193.1741961099@sss.pgh.pa.us>
	<E132D362-A669-4606-AFE1-B45C9DFCC141@yesql.se>
	<3487876.1742059377@sss.pgh.pa.us>
	<1FD7ACAC-0EBD-47D8-98B6-CC8285C571FF@yesql.se>

Daniel Gustafsson <daniel@yesql.se> 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





view thread (10+ messages)  latest in thread

Message-ID: <3791436.1742158193@sss.pgh.pa.us>
Permalink:  ../3791436.1742158193@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3791436.1742158193@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, daniel@yesql.se, 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: <3791436.1742158193@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox