summaryrefslogtreecommitdiff
path: root/src/bin/psql/command.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-11-18 13:28:13 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2014-11-18 13:28:13 -0500
commit8824bae87b78036c41ba794d96a0e68859df5990 (patch)
tree5dc73b0173baa8047dc899801de4051752cf4134 /src/bin/psql/command.c
parentab45d907b2e0ee2e27c5a2307d77dc235abec00d (diff)
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.
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r--src/bin/psql/command.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index bdf569ce35e..21cddd11ccf 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -1112,12 +1112,7 @@ exec_command(const char *cmd,
while ((opt = psql_scan_slash_option(scan_state,
OT_NORMAL, NULL, false)))
{
- newval = realloc(newval, strlen(newval) + strlen(opt) + 1);
- if (!newval)
- {
- psql_error("out of memory\n");
- exit(EXIT_FAILURE);
- }
+ newval = pg_realloc(newval, strlen(newval) + strlen(opt) + 1);
strcat(newval, opt);
free(opt);
}