summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2016-02-12 17:14:45 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2016-02-12 17:14:45 -0300
commitdb94419ffd6833da27176f6cca843483b4515065 (patch)
tree95d42607c0f577fefed4ff9bb4e6ca87c9a40394 /src
parentd03130d378b5fb071d231a7822784ad87268583a (diff)
pgbench: fix segfault with empty sql file
Commit 1d0c3b3f8a introduced a bug that causes pgbench to crash if an empty script file is specified. Fix it by rejecting such files at startup, which is the historical and intended behavior. Reported-By: Jeff Janes Discussion: https://www.postgresql.org/message-id/CAMkU=1zxKUbLPOt9hQWFp14pTc=V0cGo2GQBbn2GsK2Pu+8ZfA@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/bin/pgbench/pgbench.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 7eb6a2dea27..2c0a3182d34 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -2686,7 +2686,8 @@ findBuiltin(const char *name, char **desc)
static void
addScript(const char *name, Command **commands)
{
- if (commands == NULL)
+ if (commands == NULL ||
+ commands[0] == NULL)
{
fprintf(stderr, "empty command list for script \"%s\"\n", name);
exit(1);