+2025-07-29 Bruno Haible <bruno@clisp.org>
+
+ javacomp: Fix memory leak.
+ * lib/javacomp.c (execute_and_read_line): Free the line after getline()
+ failed.
+
2025-07-29 Bruno Haible <bruno@clisp.org>
git-merge-changelog: Fix essential functionality (regr. 2023-05-21).
char *line;
size_t linesize;
size_t linelen;
- int exitstatus;
/* Open a pipe to the program. */
child = create_pipe_in (progname, prog_path, prog_argv, NULL, NULL,
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')
- line[linelen - 1] = '\0';
+ else
+ {
+ int exitstatus;
+
+ if (linelen > 0 && line[linelen - 1] == '\n')
+ line[linelen - 1] = '\0';
- /* Read until EOF (otherwise the child process may get a SIGPIPE signal). */
- while (getc (fp) != EOF)
- ;
+ /* Read until EOF (otherwise the child process may get a SIGPIPE signal). */
+ while (getc (fp) != EOF)
+ ;
- fclose (fp);
+ fclose (fp);
- /* Remove zombie process from process list, and retrieve exit status. */
- exitstatus =
- wait_subprocess (child, progname, true, false, true, false, NULL);
- if (exitstatus != 0)
- {
- free (line);
- return NULL;
+ /* Remove zombie process from process list, and retrieve exit status. */
+ exitstatus =
+ wait_subprocess (child, progname, true, false, true, false, NULL);
+ if (exitstatus == 0)
+ return line;
}
-
- return line;
+ free (line);
+ return NULL;
}
/* Executes a program, assumed to be a Java compiler with '-version' option.