Fix parsePGArray() error checking in pg_dump.
Coverity complained about a defect in commit 257836a7: Calling "parsePGArray" without checking return value (as is done elsewhere 11 out of 13 times). Fix, and also check for empty strings explicitly (NULL as represented by PQgetvalue()). That worked correctly before only because parsePGArray() happens to set *nitems = 0 when it fails on an empty string. Also convert a sanity check assertion to an error to be more paranoid, and pgindent a nearby line. Reported-by: Michael Paquier <michael@paquier.xyz>
This commit is contained in:
parent
8b39345a9d
commit
3636efa119
|
@ -18573,13 +18573,25 @@ appendIndexCollationVersion(PQExpBuffer buffer, IndxInfo *indxinfo, int enc,
|
|||
}
|
||||
|
||||
/* Restore the versions that were recorded by the old cluster (if any). */
|
||||
parsePGArray(inddependcollnames,
|
||||
if (strlen(inddependcollnames) == 0 && strlen(inddependcollversions) == 0)
|
||||
{
|
||||
ninddependcollnames = ninddependcollversions = 0;
|
||||
inddependcollnamesarray = inddependcollversionsarray = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!parsePGArray(inddependcollnames,
|
||||
&inddependcollnamesarray,
|
||||
&ninddependcollnames);
|
||||
parsePGArray(inddependcollversions,
|
||||
&ninddependcollnames))
|
||||
fatal("could not parse index collation name array");
|
||||
if (!parsePGArray(inddependcollversions,
|
||||
&inddependcollversionsarray,
|
||||
&ninddependcollversions);
|
||||
Assert(ninddependcollnames == ninddependcollversions);
|
||||
&ninddependcollversions))
|
||||
fatal("could not parse index collation version array");
|
||||
}
|
||||
|
||||
if (ninddependcollnames != ninddependcollversions)
|
||||
fatal("mismatched number of collation names and versions for index");
|
||||
|
||||
if (ninddependcollnames > 0)
|
||||
appendPQExpBufferStr(buffer,
|
||||
|
|
Loading…
Reference in New Issue