Re: Fix some resources leaks (src/bin/pg_basebackup/pg_createsubscriber.c) - Mailing list pgsql-hackers

From Euler Taveira
Subject Re: Fix some resources leaks (src/bin/pg_basebackup/pg_createsubscriber.c)
Date
Msg-id 7c1ec392-bd03-40aa-8a2a-81969af2f1cd@app.fastmail.com
Whole thread Raw
In response to [MASSMAIL] Fix some resources leaks (src/bin/pg_basebackup/pg_createsubscriber.c)  (Ranier Vilela <ranier.vf@gmail.com>)
Responses Re: Fix some resources leaks (src/bin/pg_basebackup/pg_createsubscriber.c)
Re: Fix some resources leaks (src/bin/pg_basebackup/pg_createsubscriber.c)
List pgsql-hackers
On Wed, Mar 27, 2024, at 8:50 PM, Ranier Vilela wrote:
Coverity has some reports in the new code
pg_createsubscriber.c
I think that Coverity is right.

It depends on your "right" definition. If your program execution is ephemeral
and the leak is just before exiting, do you think it's worth it?

1.
CID 1542682: (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable buf going out of scope leaks the storage it points to.

It will exit in the next instruction.

2.
CID 1542704: (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable conn going out of scope leaks the storage it points to.

The connect_database function whose exit_on_error is false is used in 2 routines:

* cleanup_objects_atexit: that's about to exit;
* drop_primary_replication_slot: that will execute a few routines before exiting.

3.
CID 1542691: (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable str going out of scope leaks the storage it points to.

It will exit in the next instruction.

Having said that, applying this patch is just a matter of style.


--
Euler Taveira

pgsql-hackers by date:

Previous
From: Melanie Plageman
Date:
Subject: Re: Combine Prune and Freeze records emitted by vacuum
Next
From: Richard Guo
Date:
Subject: Re: Remove some redundant set_cheapest() calls