texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/parsetexi/macro.c (expand_macro_a


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/parsetexi/macro.c (expand_macro_arguments): always allocate 2 arg_list elements, for an argument, which can be an empty string, and the null delimiter. Initialize arg_space to 2 accordingly (found through valgrind output).
Date: Sun, 05 Feb 2023 19:04:53 -0500

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 75634b99be * tp/Texinfo/XS/parsetexi/macro.c (expand_macro_arguments): 
always allocate 2 arg_list elements, for an argument, which can be an empty 
string, and the null delimiter.  Initialize arg_space to 2 accordingly (found 
through valgrind output).
75634b99be is described below

commit 75634b99be6849a53a4ba3c48e0327d7ab73d4b6
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Feb 6 01:04:43 2023 +0100

    * tp/Texinfo/XS/parsetexi/macro.c (expand_macro_arguments): always
    allocate 2 arg_list elements, for an argument, which can be an empty
    string, and the null delimiter.  Initialize arg_space to 2
    accordingly (found through valgrind output).
---
 ChangeLog                       |  7 +++++++
 tp/Texinfo/XS/parsetexi/macro.c | 11 +++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b8ab30a623..5b66a01296 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-02-05  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/parsetexi/macro.c (expand_macro_arguments): always
+       allocate 2 arg_list elements, for an argument, which can be an empty
+       string, and the null delimiter.  Initialize arg_space to 2
+       accordingly (found through valgrind output).
+
 2023-02-05  Patrice Dumas  <pertusus@free.fr>
 
        * tp/t/test_utils.pl (run_all), tp/t/README: process all the tests
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index a8847bb089..8d49c7d2dc 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -251,9 +251,11 @@ expand_macro_arguments (ELEMENT *macro, char **line_inout, 
enum command_id cmd)
 
   char **arg_list = 0;
   size_t arg_number = 0;
-  size_t arg_space = 0;
+  size_t arg_space = 2;
 
-  arg_list = malloc (sizeof (char *));
+  /* minimum 2 element in arg_list, an argument, which can be an empty string 
and
+     the null delimiter */
+  arg_list = malloc (sizeof (char *) * 2);
   args_total = macro->args.number - 1;
 
   text_init (&arg);
@@ -325,6 +327,11 @@ expand_macro_arguments (ELEMENT *macro, char **line_inout, 
enum command_id cmd)
               /* Add the last argument read to the list. */
               if (arg_number == arg_space)
                 {
+                  /* note that if args_total is 0, new_arg_space will be 1
+                     which is not enough for the minimum of an argument and
+                     the terminating null element.  However, it is not possible
+                     to have arg_number == arg_space in that case, as arg_space
+                     is minimum 2 and arg_number is maximum 0 if args_total is 
0 */
                   /* Include space for terminating null element. */
                   size_t new_arg_space = args_total + 1;
                   /* unless at the end, only allocate next 5 args */



reply via email to

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