summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian2012-08-10 21:14:47 +0000
committerBruce Momjian2012-08-10 21:14:47 +0000
commite2af6537b5c81d9354e08896012cdd5c38bea311 (patch)
tree6fae3a89f9dc0dc00975cd4706ce15c275e3956b
parent63e719ec511f99eeb4f237366ef633cd264e40da (diff)
Prevent pg_upgrade from crashing if it can't write to the current
directory. Backpatch to 9.2.
-rw-r--r--contrib/pg_upgrade/util.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/pg_upgrade/util.c b/contrib/pg_upgrade/util.c
index 1c7120471f8..2c0dfd65e4e 100644
--- a/contrib/pg_upgrade/util.c
+++ b/contrib/pg_upgrade/util.c
@@ -78,7 +78,8 @@ pg_log(eLogType type, char *fmt,...)
va_end(args);
/* PG_VERBOSE is only output in verbose mode */
- if (type != PG_VERBOSE || log_opts.verbose)
+ /* fopen() on log_opts.internal might have failed, so check it */
+ if ((type != PG_VERBOSE || log_opts.verbose) && log_opts.internal != NULL)
{
fwrite(message, strlen(message), 1, log_opts.internal);
/* if we are using OVERWRITE_MESSAGE, add newline to log file */