Avoid platform-specific null pointer dereference in psql. POSIX permits getopt() to advance optind beyond argc when the last argv entry is an option that requires an argument and hasn't got one. It seems that no major platforms actually do that, but musl does, so that something like "psql -f" would crash with that libc. Add a check that optind is in range before trying to look at the possibly-bogus option.
Report and fix by Quentin Rameau. Back-patch to all supported branches. Discussion: https://postgr.es/m/[email protected] Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/fb55e95396caa5f03dc37f72522313eb5c095ee1 Modified Files -------------- src/bin/psql/startup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
