From: Bruno Haible Date: Thu, 1 May 2025 15:28:06 +0000 (+0200) Subject: javacomp: Fix resource leak. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=320db6ee7a3cd44ee77f09d30c8a9002159beb4b;p=gnulib.git 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/ChangeLog b/ChangeLog index 2749ca7eed..ca29306255 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2025-05-01 Bruno Haible + + javacomp: Fix resource leak. + * lib/javacomp.c (execute_and_read_line): Upon failure, close the stream + and wait for the child process to terminate. + 2025-04-28 Bruno Haible sigsegv: Fix compilation error on Mac OS X 10.4/powerpc. diff --git a/lib/javacomp.c b/lib/javacomp.c index 107f373740..03484be9f7 100644 --- a/lib/javacomp.c +++ b/lib/javacomp.c @@ -1,5 +1,5 @@ /* Compile a Java program. - Copyright (C) 2001-2003, 2006-2024 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2006-2025 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify @@ -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')