Re: BUG #19595: Three memory-safety defects in src/backend/tsearch/spell.c (dictionary loader), PG 18.3

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>
Cc: Alexander Lakhin <exclusion(at)gmail(dot)com>, michaelmalis2(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19595: Three memory-safety defects in src/backend/tsearch/spell.c (dictionary loader), PG 18.3
Date: 2026-08-30 15:14:03
Message-ID: 491621.1788102843@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com> writes:
> In the backend, snowball_runtime.h remaps malloc to palloc
> (src/include/snowball/snowball_runtime.h). api.c includes that
> header via the -I order in the snowball Makefile / meson.build, so
> SN_new_env()'s malloc is palloc. On allocation failure palloc does
> not return NULL. It goes through MemoryContextAllocationFailure().

Ah, right. You can confirm that SN_new_env is really using palloc:

$ nm --ext --undef api.o | grep alloc
U palloc

It's like this to prevent memory leaks while not modifying the
machine-generated Snowball .c files, but I concede it's confusing.

Anyway it looks like we have nothing to do here. The Snowball code
is correct on its own terms to defend against null results, but our
calling code is equally correct to not worry about that.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2026-08-30 17:08:49 BUG #19647: Difference in pg_basebackup behaviour between PostgreSQL <= 16 and >= 17 with pgactive extension
Previous Message Andrey Rachitskiy 2026-08-30 11:43:32 Re: BUG #19595: Three memory-safety defects in src/backend/tsearch/spell.c (dictionary loader), PG 18.3