Hello,

There's a mem leak in 'info_read_completing_internal' function
(echo-area.c:911).

In indefinite 'while(1)' cycle, storage is returned from allocation
function 'echo_area_after_read' into 'line' pointer variable (line 946).

If the cycle repeats ('continue' in '/* If no match, go back and try
again. */' case on line 982), the 'line' pointer is overwritten, which
leaks the storage 'line' originally pointed to.

Steps to reproduce:
1) run '$ valgrind --leak-check=full info gcc'
2) hit 'f' key ('Follow xref:' appears in echo area)
3) write 's?' and hit ENTER ('[No completions]' appears in echo area)
4) leave info (hit ESC, ESC and 'q' key) and see valgrind summary

If you hit ENTER more often in step number three, the amount of leaked
memory will increase.

Attached patch resolves the issue.

Best regards,
Vita

-- 
Vitezslav Crhonek
Software Engineer
Red Hat
diff -up ./info/echo-area.c.orig ./info/echo-area.c
--- ./info/echo-area.c.orig	2018-07-26 09:07:51.174145974 +0200
+++ ./info/echo-area.c	2018-07-26 09:09:40.800650603 +0200
@@ -979,6 +979,7 @@ info_read_completing_internal (const cha
                 inform_in_echo_area (_("No completions"));
               else
                 inform_in_echo_area (_("Not complete"));
+              free (line);
               continue;
             }
         }

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to