From 8b13e5c6c0e8a6b797370fb91d207031df5e784a Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 18 Nov 2014 13:28:06 -0500 Subject: 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. --- src/bin/psql/command.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/bin/psql/command.c') diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 260893523a5..3a884028b54 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -1133,12 +1133,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); } -- cgit v1.2.3