aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2025-05-28 00:10:12 +0000
committerNIIBE Yutaka <[email protected]>2025-05-28 00:10:12 +0000
commit98d8f3d396b58d3086fd0416246908eba078917b (patch)
tree8b008c1d244772673ab3158f7b456293e9c1a350
parentTime for a new error code; this time GPG_ERR_UNEXPECTED_PACKET (diff)
downloadlibgpg-error-98d8f3d396b58d3086fd0416246908eba078917b.tar.gz
libgpg-error-98d8f3d396b58d3086fd0416246908eba078917b.zip
yat2m: Release the memory after the use.
* doc/yat2m.c (add_content): Fix the type of LINE. (finish_page): Clean up. -- Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--doc/yat2m.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/doc/yat2m.c b/doc/yat2m.c
index a7f072e..ebb323c 100644
--- a/doc/yat2m.c
+++ b/doc/yat2m.c
@@ -940,7 +940,7 @@ roff_alternate (const char *line, const char *mode)
/* Add the content of LINE to the section named SECTNAME. */
static void
-add_content (const char *sectname, char *line, int verbatim)
+add_content (const char *sectname, const char *line, int verbatim)
{
section_buffer_t sect;
line_buffer_t lb;
@@ -1937,7 +1937,24 @@ finish_page (void)
fclose (fp);
free (thepage.name);
thepage.name = NULL;
- /* FIXME: Cleanup the content. */
+
+ for (i=0; i < thepage.n_sections; i++)
+ {
+ line_buffer_t line, line_next;
+
+ sect = thepage.sections + i;
+ for (line = sect->lines; line; line = line_next)
+ {
+ line_next = line->next;
+ free (line->line);
+ free (line);
+ }
+
+ free (sect->name);
+ }
+
+ free (thepage.sections);
+ thepage.n_sections = 0;
}
@@ -2227,7 +2244,6 @@ parse_file (const char *fname, FILE *fp, char **section_name, int in_pause)
add_content (*section_name, line, 1);
else if (got_line && thepage.name && *section_name && !in_pause)
add_content (*section_name, line, 0);
-
}
if (ferror (fp))
err ("%s:%d: read error: %s", fname, lnr, strerror (errno));