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

From Tom Lane
Subject Re: BUG #19595: Three memory-safety defects in src/backend/tsearch/spell.c (dictionary loader), PG 18.3
Date
Msg-id 491621.1788102843@sss.pgh.pa.us
Whole thread
In response to Re: BUG #19595: Three memory-safety defects in src/backend/tsearch/spell.c (dictionary loader), PG 18.3  (Andrey Rachitskiy <pl0h0yp1@gmail.com>)
List pgsql-bugs
Andrey Rachitskiy <pl0h0yp1@gmail.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



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #19595: Three memory-safety defects in src/backend/tsearch/spell.c (dictionary loader), PG 18.3
Next
From: Andrey Rachitskiy
Date:
Subject: Re: BUG #19487: Error while executing SQL query involving XML parsing