From: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pm91(dot)arapov(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #18845: DEREF_OF_NULL.RET guc_malloc possibly returns NULL |
Date: | 2025-03-17 08:26:43 |
Message-ID: | 6E22AA8E-26C4-4689-B9D6-E31DC1B754D3@yesql.se |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
> On 16 Mar 2025, at 21:49, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Daniel Gustafsson <daniel(at)yesql(dot)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.
AFAICT it depends on the value of PG_O_DIRECT, but leaving them is the safe
option as they will be cleaned anyways.
> 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);
I was contemplating that but skipped it due to the really good comments in the
same function, but you are right that we might as well direct the reader.
--
Daniel Gustafsson
Attachment | Content-Type | Size |
---|---|---|
v3-0001-Fix-guc_malloc-calls-consistency-and-OOM-checks.patch | application/octet-stream | 8.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Langote | 2025-03-17 12:21:22 | Re: BUG #18830: ExecInitMerge Segfault on MERGE |
Previous Message | Viktor Holmberg | 2025-03-16 21:33:21 | Re: ISN extension - wrong volatility level for isn_weak() function |