Re: Avoid handle leak (src/bin/pg_ctl/pg_ctl.c)

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid handle leak (src/bin/pg_ctl/pg_ctl.c)
Date: 2025-10-24 05:57:40
Message-ID: aPsVVEbXL6Yu9nVT@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bryan Green 2025-10-24 06:02:47 Re: pg_ctl start may return 0 even if the postmaster has been already started on Windows
Previous Message Michael Paquier 2025-10-24 05:54:22 Re: [Proposal] Adding callback support for custom statistics kinds