texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * info/session.c (info_menu_or_ref_item, info_int


From: Gavin D. Smith
Subject: branch master updated: * info/session.c (info_menu_or_ref_item, info_intuit_options_node) (info_goto_invocation_node): Use xasprintf instead of xmalloc/sprintf. The previous code appeared not to allocate memory for a final null.
Date: Tue, 15 Oct 2024 16:27:46 -0400

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

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 9fa8e5a18f * info/session.c (info_menu_or_ref_item, 
info_intuit_options_node) (info_goto_invocation_node): Use xasprintf instead of 
xmalloc/sprintf. The previous code appeared not to allocate memory for a final 
null.
9fa8e5a18f is described below

commit 9fa8e5a18f5e9dad2323a04813d6b990571ed413
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Tue Oct 15 21:27:39 2024 +0100

    * info/session.c (info_menu_or_ref_item, info_intuit_options_node)
    (info_goto_invocation_node): Use xasprintf instead of xmalloc/sprintf.
    The previous code appeared not to allocate memory for a final null.
    
    Report from Vitezslav Crhonek.
---
 ChangeLog      |  8 ++++++++
 info/session.c | 19 ++++---------------
 2 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 868fd3c335..0e0bd52ce7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-10-15  Gavin Smith <gavinsmith0123@gmail.com>
+
+       * info/session.c (info_menu_or_ref_item, info_intuit_options_node)
+       (info_goto_invocation_node): Use xasprintf instead of xmalloc/sprintf.
+       The previous code appeared not to allocate memory for a final null.
+
+       Report from Vitezslav Crhonek.
+
 2024-10-15  Vitezslav Crhonek  <vcrhonek@redhat.com>
 
        * info/infomap.c (fetch_user_maps): fix resource leak
diff --git a/info/session.c b/info/session.c
index 660e8e477a..7ed13946e5 100644
--- a/info/session.c
+++ b/info/session.c
@@ -2340,22 +2340,14 @@ info_menu_or_ref_item (WINDOW *window, int menu_item, 
int xref, int ask_p)
       if (menu_item && !xref)
         {
           if (defentry)
-            {
-              prompt = xmalloc (strlen (defentry->label)
-                                + strlen (_("Menu item (%s): ")));
-              sprintf (prompt, _("Menu item (%s): "), defentry->label);
-            }
+            xasprintf (&prompt, _("Menu item (%s): "), defentry->label);
           else
             prompt = xstrdup (_("Menu item: "));
         }
       else
         {
           if (defentry)
-            {
-              prompt = xmalloc (strlen (defentry->label)
-                                + strlen (_("Follow xref (%s): ")));
-              sprintf (prompt, _("Follow xref (%s): "), defentry->label);
-            }
+            xasprintf (&prompt, _("Follow xref (%s): "), defentry->label);
           else
             prompt = xstrdup (_("Follow xref: "));
         }
@@ -3508,8 +3500,7 @@ info_intuit_options_node (NODE *node, char *program)
         {
           char *nodename;
 
-          nodename = xmalloc (strlen (program) + strlen (*try_node));
-          sprintf (nodename, *try_node, program);
+          xasprintf (&nodename, *try_node, program);
           /* The last resort "%s" is dangerous, so we restrict it
              to exact matches here.  */
           entry = info_get_menu_entry_by_label
@@ -3583,9 +3574,7 @@ DECLARE_INFO_COMMAND (info_goto_invocation_node,
   file_name = window->node->fullpath;
   default_program_name = program_name_from_file_name (file_name);
 
-  prompt = xmalloc (strlen (default_program_name) +
-                   strlen (invocation_prompt));
-  sprintf (prompt, invocation_prompt, default_program_name);
+  xasprintf (&prompt, invocation_prompt, default_program_name);
   line = info_read_in_echo_area (prompt);
   free (prompt);
   if (!line)



reply via email to

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