Skip to content

Commit 95eb4cd

Browse files
committed
Avoid possible segfault in psql's tab completion.
Fix oversight in bd1276a: 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
1 parent fd64ed6 commit 95eb4cd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/bin/psql/tab-complete.in.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,7 @@ psql_completion(const char *text, int start, int end)
20242024
* check if that was the previous word. If so, execute the query to get a
20252025
* list of them.
20262026
*/
2027-
if (matches == NULL)
2027+
if (matches == NULL && previous_words_count > 0)
20282028
{
20292029
const pgsql_thing_t *wac;
20302030

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy