Re: Avoid possible dereference null pointer (src/backend/catalog/pg_depend.c) - Mailing list pgsql-hackers

From Ranier Vilela
Subject Re: Avoid possible dereference null pointer (src/backend/catalog/pg_depend.c)
Date
Msg-id CAEudQAoPQd6WJ13qfNu49JthpRrvUV__uUmGg+4w20udd-Wa6Q@mail.gmail.com
Whole thread Raw
In response to Re: Avoid possible dereference null pointer (src/backend/catalog/pg_depend.c)  (Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>)
Responses Re: Avoid possible dereference null pointer (src/backend/catalog/pg_depend.c)
List pgsql-hackers
Em sex., 24 de mai. de 2024 às 08:48, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> escreveu:


On Fri, May 24, 2024 at 12:16 PM Michael Paquier <michael@paquier.xyz> wrote:
On Fri, May 24, 2024 at 11:58:51AM +0530, Ashutosh Bapat wrote:
> If we are looking for avoiding a segfault and get a message which helps
> debugging, using get_attname and get_attnum might be better options.
> get_attname throws an error. get_attnum doesn't throw an error and returns
> InvalidAttnum which won't return any valid identity sequence, and thus
> return a NIL sequence list which is handled in that function already. Using
> these two functions will avoid the clutter as well as segfault. If that's
> acceptable, I will provide a patch.

Yeah, you could do that with these two routines as well.  The result
would be the same in terms of runtime validity checks.

PFA patch using those two routines. 
The function *get_attname* palloc the result name (pstrdup).
Isn't it necessary to free the memory here (pfree)?

best regards,
Ranier Vilela

pgsql-hackers by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: Avoid possible dereference null pointer (src/backend/catalog/pg_depend.c)
Next
From: Srinath Reddy Sadipiralla
Date:
Subject: Question: Why Are File Descriptors Not Closed and Accounted for PostgreSQL Backends?