BUG #15103: Do not use pfree() to free pg_malloc() return value invacuum_one_database()

Поиск
Список
Период
Сортировка
От PG Bug reporting form
Тема BUG #15103: Do not use pfree() to free pg_malloc() return value invacuum_one_database()
Дата
Msg-id 152055916778.4972.13890764985392726175@wrigleys.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #15103: Do not use pfree() to free pg_malloc() return valuein vacuum_one_database()
Список pgsql-bugs
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 }


В списке pgsql-bugs по дате отправления:

Предыдущее
От: Chris Travers
Дата:
Сообщение: When using multiple inheritance, insufficient tests exist for whethera data type change is safe.
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #15104: Double free in the main function in ecpg.c