pgsql: Fix multiple bugs and infelicities in pg_rewind.

Started by Tom Laneabout 11 years ago3 messagescomitters
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

Fix multiple bugs and infelicities in pg_rewind.

Bugs all spotted by Coverity, including wrong realloc() size request
and memory leaks. Cosmetic improvements by me.

The usage of the global variable "filemap" here is still pretty awful,
but at least I got rid of the gratuitous aliasing in several routines
(which was helping to annoy Coverity, as well as being a bug risk).

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/c67f366fa9f748257861ee233b47b80eb5ffa857

Modified Files
--------------
src/bin/pg_rewind/filemap.c | 60 +++++++++++++++++++++------------------
src/bin/pg_rewind/filemap.h | 24 ++++++----------
src/bin/pg_rewind/libpq_fetch.c | 4 +++
src/bin/pg_rewind/pg_rewind.c | 2 +-
4 files changed, 46 insertions(+), 44 deletions(-)

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

#2Michael Paquier
michael@paquier.xyz
In reply to: Tom Lane (#1)
Re: pgsql: Fix multiple bugs and infelicities in pg_rewind.

On Mon, Mar 30, 2015 at 9:02 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Fix multiple bugs and infelicities in pg_rewind.

Bugs all spotted by Coverity, including wrong realloc() size request
and memory leaks. Cosmetic improvements by me.

The usage of the global variable "filemap" here is still pretty awful,
but at least I got rid of the gratuitous aliasing in several routines
(which was helping to annoy Coverity, as well as being a bug risk).

Coverity points out that a call to PQclear() in receiveFileChunks of
libpq_fetch.c is missing as the result still leaks resources when
status is PGRES_TUPLES_OK. Please see the patch attached.
--
Michael

Attachments:

20150412_pgrewind_leak.patchtext/x-patch; charset=US-ASCII; name=20150412_pgrewind_leak.patchDownload+1-0
#3Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Michael Paquier (#2)
Re: pgsql: Fix multiple bugs and infelicities in pg_rewind.

On 04/12/2015 11:46 AM, Michael Paquier wrote:

On Mon, Mar 30, 2015 at 9:02 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Fix multiple bugs and infelicities in pg_rewind.

Bugs all spotted by Coverity, including wrong realloc() size request
and memory leaks. Cosmetic improvements by me.

The usage of the global variable "filemap" here is still pretty awful,
but at least I got rid of the gratuitous aliasing in several routines
(which was helping to annoy Coverity, as well as being a bug risk).

Coverity points out that a call to PQclear() in receiveFileChunks of
libpq_fetch.c is missing as the result still leaks resources when
status is PGRES_TUPLES_OK. Please see the patch attached.

Applied, thanks.

- Heikki

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers