[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6210] parsetexi fix some memory leaks
From: |
Gavin D. Smith |
Subject: |
[6210] parsetexi fix some memory leaks |
Date: |
Thu, 09 Apr 2015 10:41:40 +0000 |
Revision: 6210
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6210
Author: gavin
Date: 2015-04-09 10:41:39 +0000 (Thu, 09 Apr 2015)
Log Message:
-----------
parsetexi fix some memory leaks
Modified Paths:
--------------
trunk/parsetexi/end_line.c
trunk/parsetexi/handle_commands.c
trunk/parsetexi/input.c
trunk/parsetexi/parser.c
trunk/parsetexi/tree.c
Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c 2015-04-07 10:52:27 UTC (rev 6209)
+++ trunk/parsetexi/end_line.c 2015-04-09 10:41:39 UTC (rev 6210)
@@ -152,6 +152,7 @@
ELEMENT *E = new_element (ET_NONE); \
text_append (&E->text, string); \
add_to_element_contents (line_args, E); \
+ free (string); \
} while (0)
ELEMENT *line_args;
@@ -357,10 +358,9 @@
goto defindex_reserved;
}
+ add_index (name, cmd == CM_defcodeindex ? 1 : 0);
ADD_ARG (name);
- add_index (name, cmd == CM_defcodeindex ? 1 : 0);
-
break;
defindex_invalid:
line_errorf ("bad argument to @%s: %s",
@@ -614,8 +614,8 @@
elements? */
ELEMENT *first;
first = malloc (sizeof (ELEMENT));
+ memcpy (first, trimmed->contents.list[0], sizeof (ELEMENT));
first->parent_type = route_not_in_tree;
- memcpy (first, trimmed->contents.list[0], sizeof (ELEMENT));
first->text.text = malloc (first->text.space);
memcpy (first->text.text,
trimmed->contents.list[0]->text.text + 1,
@@ -667,6 +667,8 @@
insert_into_contents (trimmed, after, 0);
}
+ if (e->parent_type == route_not_in_tree)
+ destroy_element (e);
break;
}
}
@@ -684,6 +686,7 @@
{
result->node_content = 0;
result->normalized = "";
+ destroy_element (trimmed);
}
return result;
}
@@ -891,6 +894,8 @@
if (end_id == 0 || !(command_data(end_id).flags & CF_block))
{
/* error - unknown @end */
+ command_warnf ("unknown @end %s", end_command);
+ free (end_command); end_command = 0;
}
else
{
@@ -1036,6 +1041,7 @@
if (close_preformatted_command (end_id))
current = begin_preformatted (current);
}
+ free (end_command);
} /* 3340 */
else
{
Modified: trunk/parsetexi/handle_commands.c
===================================================================
--- trunk/parsetexi/handle_commands.c 2015-04-07 10:52:27 UTC (rev 6209)
+++ trunk/parsetexi/handle_commands.c 2015-04-09 10:41:39 UTC (rev 6210)
@@ -134,6 +134,14 @@
if (args->contents.number > 0 && arg_spec != MISC_skipline)
add_extra_key_misc_args (misc, "misc_args", args);
+ else
+ {
+ for (i = 0; i < args->contents.number; i++)
+ {
+ destroy_element (args->contents.list[i]);
+ }
+ destroy_element (args);
+ }
}
/* if (!ignore_global_commands)
@@ -164,6 +172,7 @@
line_arg = 1;
/* 4439 */
+ /*************************************************************/
/* Special handling of @item because it can appear
in several contents: in an @itemize, a @table, or
a @multitable. */
Modified: trunk/parsetexi/input.c
===================================================================
--- trunk/parsetexi/input.c 2015-04-07 10:52:27 UTC (rev 6209)
+++ trunk/parsetexi/input.c 2015-04-09 10:41:39 UTC (rev 6210)
@@ -136,6 +136,7 @@
line_nr.line_nr++;
return line;
}
+ free (line); line = 0;
break;
default:
abort ();
Modified: trunk/parsetexi/parser.c
===================================================================
--- trunk/parsetexi/parser.c 2015-04-07 10:52:27 UTC (rev 6209)
+++ trunk/parsetexi/parser.c 2015-04-09 10:41:39 UTC (rev 6210)
@@ -150,6 +150,7 @@
ELEMENT *l;
/* FIXME: _next_text isn't used in Perl. */
+ free (line);
line = next_text ();
if (!line)
abort (); /* Empty file? */
@@ -776,11 +777,13 @@
{
char *command = read_command_name (&line_after_command);
- if (!command || !(cmd = lookup_command (command)))
+ if (command)
{
- /* Unknown command */
- //abort ();
+ cmd = lookup_command (command);
+ if (!cmd)
+ line_errorf ("unknown command `%s'", command); // 4877
}
+ free (command);
}
}
Modified: trunk/parsetexi/tree.c
===================================================================
--- trunk/parsetexi/tree.c 2015-04-07 10:52:27 UTC (rev 6209)
+++ trunk/parsetexi/tree.c 2015-04-09 10:41:39 UTC (rev 6210)
@@ -20,11 +20,15 @@
#include "tree_types.h"
#include "tree.h"
+//int element_counter;
+
ELEMENT *
new_element (enum element_type type)
{
ELEMENT *e = malloc (sizeof (ELEMENT));
+ //element_counter++;
+
/* Zero all elements */
memset (e, 0, sizeof (*e));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6210] parsetexi fix some memory leaks,
Gavin D. Smith <=