Fix resource leak (src/bin/pg_combinebackup/pg_combinebackup.c)

Started by Ranier Vilelaover 2 years ago2 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

never appliedCI history
Jump to latest
#1Ranier Vilela
ranier.vf@gmail.com

Hi,

Per Coverity.

The function scan_for_existing_tablespaces in
(src/bin/pg_combinebackup/pg_combinebackup.c)
Has a resource leak.

The function opendir opendir
<https://pubs.opengroup.org/onlinepubs/009604599/functions/opendir.html&gt;
Must be freed with closedir
<https://pubs.opengroup.org/onlinepubs/009604599/functions/closedir.html&gt;

The commit affected is dc21234
<http://dc212340058b4e7ecfc5a7a81ec50e7a207bf288&gt;

Trivial patch attached.

Best regards,
Ranier Vilela

Attachments:

fix-resource-leak-pg_combinebackup.patchapplication/octet-stream; name=fix-resource-leak-pg_combinebackup.patchDownload+1-0
#2Michael Paquier
michael@paquier.xyz
In reply to: Ranier Vilela (#1)
Re: Fix resource leak (src/bin/pg_combinebackup/pg_combinebackup.c)

Hi Ranier,

On Sat, Dec 30, 2023 at 10:34:12AM -0300, Ranier Vilela wrote:

The function scan_for_existing_tablespaces in
(src/bin/pg_combinebackup/pg_combinebackup.c)
Has a resource leak.

The function opendir opendir
<https://pubs.opengroup.org/onlinepubs/009604599/functions/opendir.html&gt;
Must be freed with closedir
<https://pubs.opengroup.org/onlinepubs/009604599/functions/closedir.html&gt;

The commit affected is dc21234
<http://dc212340058b4e7ecfc5a7a81ec50e7a207bf288&gt;

The community receives its own coverity reports. These are not public
but we are aware of the reports related to pg_basebackup and
pg_combinebackup as an effect of dc212340058b. Robert is planning to
handle all these AFAIK once the new year vacations and such cool down.

In short there is no need to worry here :)

Thanks for the patches.
--
Michael