texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[8327] parsetexi fix some memory leaks


From: gavinsmith0123
Subject: [8327] parsetexi fix some memory leaks
Date: Thu, 18 Oct 2018 09:26:53 -0400 (EDT)

Revision: 8327
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8327
Author:   gavin
Date:     2018-10-18 09:26:53 -0400 (Thu, 18 Oct 2018)
Log Message:
-----------
parsetexi fix some memory leaks

Modified Paths:
--------------
    trunk/tp/Texinfo/XS/parsetexi/convert.c
    trunk/tp/Texinfo/XS/parsetexi/end_line.c
    trunk/tp/Texinfo/XS/parsetexi/macro.c
    trunk/tp/Texinfo/XS/parsetexi/menus.c
    trunk/tp/Texinfo/XS/parsetexi/parser.c
    trunk/tp/Texinfo/XS/parsetexi/separator.c
    trunk/tp/Texinfo/XS/parsetexi/tree_types.h

Modified: trunk/tp/Texinfo/XS/parsetexi/convert.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/convert.c     2018-10-18 12:59:08 UTC (rev 
8326)
+++ trunk/tp/Texinfo/XS/parsetexi/convert.c     2018-10-18 13:26:53 UTC (rev 
8327)
@@ -179,6 +179,7 @@
 }
 #undef ADD
 
+/* Return value to be freed by caller. */
 char *
 convert_to_texinfo (ELEMENT *e)
 {

Modified: trunk/tp/Texinfo/XS/parsetexi/end_line.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/end_line.c    2018-10-18 12:59:08 UTC (rev 
8326)
+++ trunk/tp/Texinfo/XS/parsetexi/end_line.c    2018-10-18 13:26:53 UTC (rev 
8327)
@@ -1,6 +1,5 @@
 /* end_line.c -- what to do at the end of a whole line of input
-/* Copyright 2010, 2011, 2012, 2013, 2014, 2015
-   Free Software Foundation, Inc.
+/* Copyright 2010-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

Modified: trunk/tp/Texinfo/XS/parsetexi/macro.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/macro.c       2018-10-18 12:59:08 UTC (rev 
8326)
+++ trunk/tp/Texinfo/XS/parsetexi/macro.c       2018-10-18 13:26:53 UTC (rev 
8327)
@@ -1,5 +1,4 @@
-/* Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016
-   Free Software Foundation, Inc.
+/* Copyright 2010-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by

Modified: trunk/tp/Texinfo/XS/parsetexi/menus.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/menus.c       2018-10-18 12:59:08 UTC (rev 
8326)
+++ trunk/tp/Texinfo/XS/parsetexi/menus.c       2018-10-18 13:26:53 UTC (rev 
8327)
@@ -1,5 +1,4 @@
-/* Copyright 2010, 2011, 2012, 2013, 2014, 2015
-   Free Software Foundation, Inc.
+/* Copyright 2010-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -37,10 +36,12 @@
         {
           add_extra_element (current, "menu_entry_name", arg);
           if (arg->contents.number == 0)
-            line_warn ("empty menu entry name in `%s'",
-                       convert_to_texinfo (current));
-
-          // Check menu label isn't empty
+            {
+              char *texi = convert_to_texinfo (current);
+              line_warn ("empty menu entry name in `%s'", texi);
+              free (texi);
+            }
+          // FIXME: Check menu label isn't empty
         }
       else if (arg->type == ET_menu_entry_node)
         {

Modified: trunk/tp/Texinfo/XS/parsetexi/parser.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/parser.c      2018-10-18 12:59:08 UTC (rev 
8326)
+++ trunk/tp/Texinfo/XS/parsetexi/parser.c      2018-10-18 13:26:53 UTC (rev 
8327)
@@ -254,6 +254,7 @@
 
   free (global_info.input_perl_encoding);
 
+  free (global_info.dircategory_direntry.contents.list);
   free (global_info.footnotes.contents.list);
 
 #define GLOBAL_CASE(cmx) \

Modified: trunk/tp/Texinfo/XS/parsetexi/separator.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/separator.c   2018-10-18 12:59:08 UTC (rev 
8326)
+++ trunk/tp/Texinfo/XS/parsetexi/separator.c   2018-10-18 13:26:53 UTC (rev 
8327)
@@ -363,12 +363,15 @@
                 {
                   if (check_empty_expansion (ref->args.list[1]))
                     {
+                      char *texi = 0;
+                      if (ref->args.list[1])
+                        texi = convert_to_texinfo (ref->args.list[1]);
+
                       line_warn ("in @%s empty cross reference name "
                                  "after expansion `%s'",
                                  command_name(closed_command),
-                                 ref->args.list[1]
-                                 ? convert_to_texinfo (ref->args.list[1])
-                                 : "");
+                                 ref->args.list[1] ? texi : "");
+                      free (texi);
                     }
                 }
 
@@ -378,12 +381,15 @@
                 {
                   if (check_empty_expansion (ref->args.list[2]))
                     {
+                      char *texi = 0;
+                      if (ref->args.list[2])
+                        texi = convert_to_texinfo (ref->args.list[2]);
+
                       line_warn ("in @%s empty cross reference title "
                                  "after expansion `%s'",
                                  command_name(closed_command),
-                                 ref->args.list[2]
-                                 ? convert_to_texinfo (ref->args.list[2])
-                                 : "");
+                                 ref->args.list[2] ? texi : "");
+                      free (texi);
                     }
                 }
             }

Modified: trunk/tp/Texinfo/XS/parsetexi/tree_types.h
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/tree_types.h  2018-10-18 12:59:08 UTC (rev 
8326)
+++ trunk/tp/Texinfo/XS/parsetexi/tree_types.h  2018-10-18 13:26:53 UTC (rev 
8327)
@@ -70,14 +70,6 @@
 enum route_element_type { route_uninitialized, route_contents, route_args,
     route_not_in_tree };
 
-typedef struct {
-    /* Element that contains a reference to this one. */
-    struct ELEMENT *element;
-
-    /* Index into the referring element's extra keys that is the reference. */
-    int extra_index;
-} PENDING_REFERENCE;
-
 typedef struct ELEMENT {
     enum command_id cmd;
     TEXT text;
@@ -104,7 +96,7 @@
     char *input_encoding_name;
     char *input_perl_encoding;
     int sections_level;
-    ELEMENT dircategory_direntry;
+    ELEMENT dircategory_direntry; /* an array of elements */
 
     /* Elements that should be unique. */
     // 288 and Common.pm:164




reply via email to

[Prev in Thread] Current Thread [Next in Thread]