aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r--src/bin/psql/command.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 38038d415f1..a9a2fdbf266 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -1182,15 +1182,23 @@ exec_command(const char *cmd,
fflush(stdout);
}
result = gets_fromFile(stdin);
+ if (!result)
+ {
+ psql_error("\\%s: could not read value for variable\n",
+ cmd);
+ success = false;
+ }
}
- if (!SetVariable(pset.vars, opt, result))
+ if (result &&
+ !SetVariable(pset.vars, opt, result))
{
psql_error("\\%s: error while setting variable\n", cmd);
success = false;
}
- free(result);
+ if (result)
+ free(result);
if (prompt_text)
free(prompt_text);
free(opt);