Commit db94419f authored by Alvaro Herrera's avatar Alvaro Herrera

pgbench: fix segfault with empty sql file

Commit 1d0c3b3f 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
parent d03130d3
...@@ -2686,7 +2686,8 @@ findBuiltin(const char *name, char **desc) ...@@ -2686,7 +2686,8 @@ findBuiltin(const char *name, char **desc)
static void static void
addScript(const char *name, Command **commands) 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); fprintf(stderr, "empty command list for script \"%s\"\n", name);
exit(1); exit(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment