pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: bianpan2016@163.com
Subject: BUG #15103: Do not use pfree() to free pg_malloc() return value in vacuum_one_database()
Date: Fri, 09 Mar 2018 01:32:47 +0000
Message-ID: <152055916778.4972.13890764985392726175@wrigleys.postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15103
Logged by:          Pan Bian
Email address:      bianpan2016@163.com
PostgreSQL version: 10.3
Operating system:   Linux
Description:        

File: src/bin/scripts/vacuumdb.c
Function: vacuum_one_database()

Details: In function vacuum_one_database(), the memory allocated with
pg_malloc() (at line 435), but the return value is freed with pfree() (at
line 530). I think use the function pg_free() paired with pg_malloc() is
better here.

For your convenience, I paste related bugs as follows:

334 static void
335 vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
336                     int stage,
337                     SimpleStringList *tables,
338                     const char *host, const char *port,
339                     const char *username, enum trivalue
prompt_password,
340                     int concurrentCons,
341                     const char *progname, bool echo, bool quiet)
342 {
343     PQExpBufferData sql;
344     PGconn     *conn;
345     SimpleStringListCell *cell;
346     ParallelSlot *slots = NULL;
        ...
435     slots = (ParallelSlot *) pg_malloc(sizeof(ParallelSlot) *
concurrentCons);
436     init_slot(slots, conn, progname);
437     if (parallel)
438     {
439         for (i = 1; i < concurrentCons; i++)
440         {
441             conn = connectDatabase(dbname, host, port, username,
prompt_password,
442                                    progname, echo, false, true);
443             init_slot(slots + i, conn, progname);
444         }
445     }
        ...
527 finish:
528     for (i = 0; i < concurrentCons; i++)
529         DisconnectDatabase(slots + i);
530     pfree(slots);
531 
532     termPQExpBuffer(&sql);
533 
534     if (failed)
535         exit(1);
536 }



view thread (2+ messages)  latest in thread

Message-ID: <152055916778.4972.13890764985392726175@wrigleys.postgresql.org>
Permalink:  ../152055916778.4972.13890764985392726175@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/152055916778.4972.13890764985392726175@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, bianpan2016@163.com
  Subject: Re: BUG #15103: Do not use pfree() to free pg_malloc() return value in vacuum_one_database()
  In-Reply-To: <152055916778.4972.13890764985392726175@wrigleys.postgresql.org>
  References: <152055916778.4972.13890764985392726175@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox