Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6910032

Browse files
author
Neil Conway
committed
Upon closer inspection, Greg's psql tab completion patch leaks memory.
Fix the leak, and add a comment to note that the return value of previous_word must be free'd.
1 parent 4c1f9a0 commit 6910032

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/bin/psql/tab-complete.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.128 2005/05/18 04:47:40 neilc Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.129 2005/05/18 05:01:10 neilc Exp $
77
*/
88

99
/*----------------------------------------------------------------------
@@ -1802,6 +1802,7 @@ psql_completion(char *text, int start, int end)
18021802
free(prev2_wd);
18031803
free(prev3_wd);
18041804
free(prev4_wd);
1805+
free(prev5_wd);
18051806

18061807
/* Return our Grand List O' Matches */
18071808
return matches;
@@ -2168,9 +2169,11 @@ exec_query(const char *query)
21682169

21692170

21702171

2171-
/* Return the word (space delimited) before point. Set skip > 0 to skip that
2172-
many words; e.g. skip=1 finds the word before the previous one.
2173-
*/
2172+
/*
2173+
* Return the word (space delimited) before point. Set skip > 0 to
2174+
* skip that many words; e.g. skip=1 finds the word before the
2175+
* previous one. Return value is NULL or a malloc'ed string.
2176+
*/
21742177
static char *
21752178
previous_word(int point, int skip)
21762179
{

0 commit comments

Comments
 (0)