Skip to content

Commit db94419

Browse files
committed
pgbench: fix segfault with empty sql file
Commit 1d0c3b3 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
1 parent d03130d commit db94419

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/bin/pgbench/pgbench.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2686,7 +2686,8 @@ findBuiltin(const char *name, char **desc)
26862686
static void
26872687
addScript(const char *name, Command **commands)
26882688
{
2689-
if (commands == NULL)
2689+
if (commands == NULL ||
2690+
commands[0] == NULL)
26902691
{
26912692
fprintf(stderr, "empty command list for script \"%s\"\n", name);
26922693
exit(1);

0 commit comments

Comments
 (0)