The javacomp module has a resource leak in case of (unlikely) failure.
This patch fixes it.


2025-05-01  Bruno Haible  <br...@clisp.org>

        javacomp: Fix resource leak.
        * lib/javacomp.c (execute_and_read_line): Upon failure, close the stream
        and wait for the child process to terminate.

diff --git a/lib/javacomp.c b/lib/javacomp.c
index c024c15a66..33ec8eb63e 100644
--- a/lib/javacomp.c
+++ b/lib/javacomp.c
@@ -359,6 +359,8 @@ execute_and_read_line (const char *progname,
   if (linelen == (size_t)(-1))
     {
       error (0, 0, _("%s subprocess I/O error"), progname);
+      fclose (fp);
+      wait_subprocess (child, progname, true, false, true, false, NULL);
       return NULL;
     }
   if (linelen > 0 && line[linelen - 1] == '\n')




Reply via email to