diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2024-10-10 16:17:38 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2024-10-10 16:17:38 -0400 |
commit | 95eb4cd4ff0648afc32abbfaacc9718f6b91bf7b (patch) | |
tree | 77a05e6f59ba3669d618ee4a8eb43f1a451c1fa8 /src | |
parent | fd64ed60b62697984bb69a09a3ae19fbe2905eb6 (diff) | |
download | postgresql-95eb4cd4ff0648afc32abbfaacc9718f6b91bf7b.tar.gz postgresql-95eb4cd4ff0648afc32abbfaacc9718f6b91bf7b.zip |
Avoid possible segfault in psql's tab completion.
Fix oversight in bd1276a3c: the "words_after_create" stanza in
psql_completion() requires previous_words_count > 0, since it uses
prev_wd. This condition was formerly assured by the if-else chain
above it, but no more. If there were no previous words then we'd
dereference an uninitialized pointer, possibly causing a segfault.
Report and patch by Anthonin Bonnefoy.
Discussion: https://postgr.es/m/CAO6_XqrSRE7c_i+D7Hm07K3+6S0jTAmMr60RY41XzaA29Ae5uA@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/psql/tab-complete.in.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index a9f4d205e14..1be0056af73 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -2024,7 +2024,7 @@ psql_completion(const char *text, int start, int end) * check if that was the previous word. If so, execute the query to get a * list of them. */ - if (matches == NULL) + if (matches == NULL && previous_words_count > 0) { const pgsql_thing_t *wac; |