]> granicus.if.org Git - postgresql/commitdiff
Fix erroneous space calculation leading to core dump in dumpProcLangs,
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 3 May 2003 22:19:18 +0000 (22:19 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 3 May 2003 22:19:18 +0000 (22:19 +0000)
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.

src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_dump.c

index 3a045e830b8af597a603d3d85b83a2f50b94effb..9154ba22cdfefef4a227d705e20e04e3f318a744 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *             $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.62.2.3 2003/03/09 19:38:59 tgl Exp $
+ *             $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.62.2.4 2003/05/03 22:19:18 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1915,7 +1915,7 @@ ReadToc(ArchiveHandle *AH)
                        depIdx = 0;
                        do
                        {
-                               if (depIdx > depSize)
+                               if (depIdx >= depSize)
                                {
                                        depSize *= 2;
                                        deps = realloc(deps, sizeof(char *) * depSize);
@@ -1931,7 +1931,10 @@ ReadToc(ArchiveHandle *AH)
                        if (depIdx > 1)         /* We have a non-null entry */
                                te->depOid = realloc(deps, sizeof(char *) * depIdx);    /* trim it */
                        else
+                       {
+                               free(deps);
                                te->depOid = NULL;              /* no deps */
+                       }
                }
                else
                        te->depOid = NULL;
index 4b77c016512f642332d5b1229d7a8aca17a79d46..183d8e6ff30940560be92c1c560370e5addc89e9 100644 (file)
@@ -22,7 +22,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.305.2.4 2003/04/25 22:14:33 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.305.2.5 2003/05/03 22:19:18 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -3489,7 +3489,7 @@ dumpProcLangs(Archive *fout, FuncInfo finfo[], int numFuncs)
                resetPQExpBuffer(delqry);
 
                /* Make a dependency to ensure function is dumped first */
-               deps = malloc(sizeof(char *) * (2 + (strcmp(lanvalidator, "0") != 0) ? 1 : 0));
+               deps = malloc(sizeof(char *) * 10);
                depIdx = 0;
 
                (*deps)[depIdx++] = strdup(lanplcallfoid);