mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
Fix some bogus direct uses of realloc().
pg_dump/parallel.c was using realloc() directly with no error check. While the odds of an actual failure here seem pretty low, Coverity complains about it, so fix by using pg_realloc() instead. While looking for other instances, I noticed a couple of places in psql that hadn't gotten the memo about the availability of pg_realloc. These aren't bugs, since they did have error checks, but verbosely inconsistent code is not a good thing. Back-patch as far as 9.3. 9.2 did not have pg_dump/parallel.c, nor did it have pg_realloc available in all frontend code.
This commit is contained in:
@ -4331,13 +4331,8 @@ append_variable_names(char ***varnames, int *nvars,
|
||||
if (*nvars >= *maxvars)
|
||||
{
|
||||
*maxvars *= 2;
|
||||
*varnames = (char **) realloc(*varnames,
|
||||
((*maxvars) + 1) * sizeof(char *));
|
||||
if (!(*varnames))
|
||||
{
|
||||
psql_error("out of memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
*varnames = (char **) pg_realloc(*varnames,
|
||||
((*maxvars) + 1) * sizeof(char *));
|
||||
}
|
||||
|
||||
(*varnames)[(*nvars)++] = psprintf("%s%s%s", prefix, varname, suffix);
|
||||
|
Reference in New Issue
Block a user