Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2286971

Browse files
committed
Fix erroneous space calculation leading to core dump in dumpProcLangs,
per report from Olivier Prenant. Also fix off-by-one space calculation in ReadToc; this woould not have hurt us until we had more than 100 dependencies for a single object, but wrong is wrong.
1 parent 5295fff commit 2286971

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.70 2003/03/10 22:28:19 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.71 2003/05/03 22:18:59 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -1916,7 +1916,7 @@ ReadToc(ArchiveHandle *AH)
19161916
depIdx = 0;
19171917
do
19181918
{
1919-
if (depIdx > depSize)
1919+
if (depIdx >= depSize)
19201920
{
19211921
depSize *= 2;
19221922
deps = realloc(deps, sizeof(char *) * depSize);
@@ -1932,7 +1932,10 @@ ReadToc(ArchiveHandle *AH)
19321932
if (depIdx > 1) /* We have a non-null entry */
19331933
te->depOid = realloc(deps, sizeof(char *) * depIdx); /* trim it */
19341934
else
1935+
{
1936+
free(deps);
19351937
te->depOid = NULL; /* no deps */
1938+
}
19361939
}
19371940
else
19381941
te->depOid = NULL;

src/bin/pg_dump/pg_dump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.327 2003/04/25 02:28:22 tgl Exp $
15+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.328 2003/05/03 22:18:59 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -3591,7 +3591,7 @@ dumpProcLangs(Archive *fout, FuncInfo finfo[], int numFuncs)
35913591
resetPQExpBuffer(delqry);
35923592

35933593
/* Make a dependency to ensure function is dumped first */
3594-
deps = malloc(sizeof(char *) * (2 + (strcmp(lanvalidator, "0") != 0) ? 1 : 0));
3594+
deps = malloc(sizeof(char *) * 10);
35953595
depIdx = 0;
35963596

35973597
(*deps)[depIdx++] = strdup(lanplcallfoid);

0 commit comments

Comments
 (0)