[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[8322] parsetexi try to clear up a few memory leaks
From: |
gavinsmith0123 |
Subject: |
[8322] parsetexi try to clear up a few memory leaks |
Date: |
Thu, 18 Oct 2018 06:59:52 -0400 (EDT) |
Revision: 8322
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8322
Author: gavin
Date: 2018-10-18 06:59:51 -0400 (Thu, 18 Oct 2018)
Log Message:
-----------
parsetexi try to clear up a few memory leaks
Modified Paths:
--------------
trunk/tp/Texinfo/XS/parsetexi/end_line.c
trunk/tp/Texinfo/XS/parsetexi/indices.c
trunk/tp/Texinfo/XS/parsetexi/parser.c
Modified: trunk/tp/Texinfo/XS/parsetexi/end_line.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/end_line.c 2018-10-18 08:31:22 UTC (rev
8321)
+++ trunk/tp/Texinfo/XS/parsetexi/end_line.c 2018-10-18 10:59:51 UTC (rev
8322)
@@ -146,7 +146,7 @@
ELEMENT *args = new_element (ET_NONE);
char *p = 0, *q = 0, *r = 0;
- char *value, *remaining = 0;;
+ char *value = 0, *remaining = 0;;
switch (cmd)
{
@@ -206,6 +206,7 @@
flag = read_command_name (&q);
if (!flag)
goto clear_invalid;
+ free (flag);
r = q + strspn (q, whitespace_chars);
if (*r)
goto clear_invalid; /* Trailing argument. */
@@ -230,7 +231,7 @@
value = read_command_name (&q);
if (!value)
goto unmacro_badname;
- /* TODO: Check comment syntax is right */
+ /* FIXME: Check comment syntax is right */
delete_macro (value);
ADD_ARG(value, q - p);
debug ("UNMACRO %s", value);
@@ -252,15 +253,16 @@
if (!value)
goto clickstyle_invalid;
ADD_ARG (p - 1, q - p + 1);
- global_clickstyle = value;
+ free (global_clickstyle); global_clickstyle = value;
if (!memcmp (q, "{}", 2))
q += 2;
remaining = q;
- /* TODO: check comment */
+ /* FIXME: check comment */
break;
clickstyle_invalid:
line_error ("@clickstyle should only accept an @-command as argument, "
"not `%s'", line);
+ free (value);
break;
default:
abort ();
@@ -515,9 +517,11 @@
defindex_invalid:
line_error ("bad argument to @%s: %s",
command_name(cmd), line);
+ free (name);
break;
defindex_reserved:
line_error ("reserved index name %s", name);
+ free (name);
break;
}
case CM_synindex:
@@ -1521,6 +1525,7 @@
}
}
}
+ free (text2);
if (perl_encoding)
{
@@ -1543,7 +1548,8 @@
}
add_extra_string_dup (current, "input_perl_encoding",
perl_encoding);
- global_info.input_perl_encoding = perl_encoding;
+ free (global_info.input_perl_encoding);
+ global_info.input_perl_encoding = strdup (perl_encoding);
}
else
{
@@ -1648,7 +1654,7 @@
}
global_documentlanguage = strdup (text);
- /* TODO: check customization variable */
+ /* FIXME: check customization variable */
}
}
if (superfluous_arg)
@@ -1748,7 +1754,7 @@
}
else
{
- // 3273 possibly check for @def... command
+ // 3273 FIXME possibly check for @def... command
}
@@ -1791,7 +1797,7 @@
{
/* shouldn't get here, but got here
on 2015.11.30 for t/16raw.t */
- //abort (); // 3335
+ //FIXME abort (); // 3335
}
else
{ // 3295
@@ -1799,7 +1805,7 @@
add_extra_element (closed_command, "end_command", end_elt);
close_command_cleanup (closed_command);
- // 3301 INLINE_INSERTCOPYING
+ // 3301 FIXME INLINE_INSERTCOPYING
add_to_element_contents (closed_command, end_elt); // 3321
@@ -2243,7 +2249,6 @@
&& contents_child_by_index(current, -2)
&& contents_child_by_index(current, -2)->cmd == CM_verbatim)
{
- // I don't know what this means. raw command is @html etc.?
/*
if we are after a @end verbatim, we must restart a preformatted if needed,
since there is no @end command explicitly associated to raw commands
Modified: trunk/tp/Texinfo/XS/parsetexi/indices.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/indices.c 2018-10-18 08:31:22 UTC (rev
8321)
+++ trunk/tp/Texinfo/XS/parsetexi/indices.c 2018-10-18 10:59:51 UTC (rev
8322)
@@ -137,6 +137,7 @@
//destroy_element (ie->content);
// TODO - check if above is required
}
+ free (idx->name);
free (idx->index_entries);
}
@@ -217,7 +218,7 @@
for (p = default_indices; p->name; p++)
{
/* Both @cindex and @cpindex are added. */
- idx = add_index_internal (p->name, p->in_code);
+ idx = add_index_internal (strdup (p->name), p->in_code);
*name = p->name[0];
add_index_command (name, idx); /* @cindex */
Modified: trunk/tp/Texinfo/XS/parsetexi/parser.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/parser.c 2018-10-18 08:31:22 UTC (rev
8321)
+++ trunk/tp/Texinfo/XS/parsetexi/parser.c 2018-10-18 10:59:51 UTC (rev
8322)
@@ -112,8 +112,8 @@
/* Information that is not local to where it is set in the Texinfo input,
for example document language and encoding. */
GLOBAL_INFO global_info;
-char *global_clickstyle = "arrow";
-char *global_documentlanguage = "";
+char *global_clickstyle = 0;
+char *global_documentlanguage = 0;
enum kbd_enum global_kbdinputstyle = kbd_distinct;
@@ -245,9 +245,12 @@
void
wipe_global_info (void)
{
- global_clickstyle = "arrow";
+ free (global_clickstyle);
+ free (global_documentlanguage);
+ global_clickstyle = strdup ("arrow");
+ global_documentlanguage = strdup ("");
+
global_kbdinputstyle = kbd_distinct;
- global_documentlanguage = "";
free (global_info.footnotes.contents.list);
@@ -300,7 +303,7 @@
status = input_push_file (filename);
if (status)
{
- /* TODO document_error */
+ /* FIXME document_error */
abort ();
}
@@ -1944,12 +1947,10 @@
while (current->parent)
current = current->parent;
}
+
+ input_reset_input_stack (); /* to avoid a memory leak if @bye is given */
/* TODO: Check for "unclosed stacks". */
return current;
-} /* 5372 */
-
-
-
-/* 5793 - end of code in Parser.pm */
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [8322] parsetexi try to clear up a few memory leaks,
gavinsmith0123 <=