Re: [PATCH] bashline: small leaks

2024-05-22 Thread Chet Ramey

On 5/21/24 11:34 AM, Grisha Levit wrote:

- free directory_part when completing command words like `~/bin/'
- free contents of matches when completing command words in old-style
   command substitutions


Thanks for the report and patch.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



OpenPGP_signature.asc
Description: OpenPGP digital signature


[PATCH] bashline: small leaks

2024-05-21 Thread Grisha Levit
- free directory_part when completing command words like `~/bin/'
- free contents of matches when completing command words in old-style
  command substitutions
---
 bashline.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/bashline.c b/bashline.c
index b638e001..525d065a 100644
--- a/bashline.c
+++ b/bashline.c
@@ -2001,6 +2001,11 @@ command_word_completion_function (const char *hint_text, 
int state)
  free (glob_matches);
  glob_matches = (char **)NULL;
}
+  if (directory_part)
+{
+  free (directory_part);
+  directory_part = (char *)NULL;
+}
 
   globpat = completion_glob_pattern (hint_text);
 
@@ -2451,7 +2456,7 @@ command_subst_completion_function (const char *text, int 
state)
   filename_text = savestring (text);
   if (matches)
{
- free (matches);
+ strvec_dispose (matches);
  matches = (char **)NULL;
}
 
-- 
2.45.1