Martijn van Oosterhout wrote:
> Coverity picked up an error in dumpStdStrings() since last night. At
> line 1448 there's PQclear(res) yet it's used several times further down
> (lines 1452, 1454 and 1456).
>
> I'd actually suggest zeroing out res->tuples in PQclear so this sort of
> problem becomes much more obvious.
Is it worthwhile to zero out the res->block array as well?
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Index: src/bin/pg_dump/pg_dump.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql/src/bin/pg_dump/pg_dump.c,v
retrieving revision 1.434
diff -c -r1.434 pg_dump.c
*** src/bin/pg_dump/pg_dump.c 26 May 2006 23:48:54 -0000 1.434
--- src/bin/pg_dump/pg_dump.c 28 May 2006 15:39:14 -0000
***************
*** 1445,1452 ****
check_sql_result(res, g_conn, qry->data, PGRES_TUPLES_OK);
- PQclear(res);
-
resetPQExpBuffer(qry);
std_strings = (strcmp(PQgetvalue(res, 0, 0), "on") == 0);
--- 1445,1450 ----
***************
*** 1454,1460 ****
appendStringLiteral(qry, PQgetvalue(res, 0, 0), true,
!std_strings);
appendPQExpBuffer(qry, ";\n");
puts(PQgetvalue(res, 0, 0));
!
}
ArchiveEntry(AH, nilCatalogId, createDumpId(),
--- 1452,1459 ----
appendStringLiteral(qry, PQgetvalue(res, 0, 0), true,
!std_strings);
appendPQExpBuffer(qry, ";\n");
puts(PQgetvalue(res, 0, 0));
!
! PQclear(res);
}
ArchiveEntry(AH, nilCatalogId, createDumpId(),
Index: src/interfaces/libpq/fe-exec.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql/src/interfaces/libpq/fe-exec.c,v
retrieving revision 1.184
diff -c -r1.184 fe-exec.c
*** src/interfaces/libpq/fe-exec.c 23 May 2006 22:13:19 -0000 1.184
--- src/interfaces/libpq/fe-exec.c 28 May 2006 15:39:20 -0000
***************
*** 358,368 ****
--- 358,372 ----
{
res->curBlock = block->next;
free(block);
+ block = NULL;
}
/* Free the top-level tuple pointer array */
if (res->tuples)
+ {
free(res->tuples);
+ res->tuples = NULL;
+ }
/* Free the PGresult structure itself */
free(res);
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings