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/api.c (build_texinfo_tr


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/parsetexi/api.c (build_texinfo_tree): return an empty element instead of segfaulting if build_texinfo_tree() is called without any Root set, although this should never happen with the current code.
Date: Tue, 22 Feb 2022 12:33:44 -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 5f7c65a0a8 * tp/Texinfo/XS/parsetexi/api.c (build_texinfo_tree): 
return an empty element instead of segfaulting if build_texinfo_tree() is 
called without any Root set, although this should never happen with the current 
code.
5f7c65a0a8 is described below

commit 5f7c65a0a8f1fafb192511cb1fe60083d902c842
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Feb 22 18:31:17 2022 +0100

    * tp/Texinfo/XS/parsetexi/api.c (build_texinfo_tree): return
    an empty element instead of segfaulting if build_texinfo_tree()
    is called without any Root set, although this should never happen
    with the current code.
---
 ChangeLog                     | 7 +++++++
 tp/Texinfo/XS/parsetexi/api.c | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index f5cf027fb5..30095f681e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-02-22  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/parsetexi/api.c (build_texinfo_tree): return
+       an empty element instead of segfaulting if build_texinfo_tree()
+       is called without any Root set, although this should never happen
+       with the current code.
+
 2022-02-22  Gavin Smith  <gavinsmith0123@gmail.com>
 
        Avoid segfault in XS code for missing input file
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index 642dbaef04..240481f8be 100644
--- a/tp/Texinfo/XS/parsetexi/api.c
+++ b/tp/Texinfo/XS/parsetexi/api.c
@@ -632,6 +632,13 @@ element_to_perl_hash (ELEMENT *e)
 HV *
 build_texinfo_tree (void)
 {
+  if (! Root)
+      /* use an empty element with contents if there is nothing.
+         This should only happen if the input file was not opened
+         or no parse_* function was called after initialization
+         and should not happen with the current calling code.
+      */
+      Root = new_element (ET_NONE);
   element_to_perl_hash (Root);
   return Root->hv;
 }



reply via email to

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