Re: Avoid handle leak (src/bin/pg_ctl/pg_ctl.c) - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Avoid handle leak (src/bin/pg_ctl/pg_ctl.c)
Date
Msg-id aPsVVEbXL6Yu9nVT@paquier.xyz
Whole thread Raw
In response to Avoid handle leak (src/bin/pg_ctl/pg_ctl.c)  (Ranier Vilela <ranier.vf@gmail.com>)
Responses Re: Avoid handle leak (src/bin/pg_ctl/pg_ctl.c)
List pgsql-hackers
On Thu, Oct 23, 2025 at 09:51:14PM -0300, Ranier Vilela wrote:
> The function *CreateRestrictedProcess* is responsible to create a
> restricted token
> Coverity complains that the handle origToken can be leaked.
>
> In case of failure of the functions *AllocateAndInitializeSid* or
> *GetPrivilegesToDelete*
> the handle origToken must be released.

pg_ctl exits quickly when a failure of CreateRestrictedProcess()
happens, hence why does it matter to close these handles as an exit()
should do the job as well?
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [Proposal] Adding callback support for custom statistics kinds
Next
From: Bryan Green
Date:
Subject: Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows