texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Gavin D. Smith
Date: Sun, 25 Apr 2021 10:31:41 -0400 (EDT)

branch: master
commit 95b11e7cb4f0a541e30f37856e78e61781bdc25f
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Apr 25 15:31:24 2021 +0100

    Fix memory leaks.
    
    * info/makedoc.c (process_one_file):
    The memory is freed for both pointers at the end of the loop.
    But there is one break that leaves the loop without freeing them.
    * info/session.c (info_goto_invocation_node):
    The value of 'default_program_name' is assigned by
    program_name_from_file_name() function.
    Its description says 'Return value should be freed by caller.'
    That was not done in this case.
---
 ChangeLog      | 13 +++++++++++++
 info/makedoc.c |  8 ++++++--
 info/session.c |  1 +
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0251850..307f43e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2021-04-25  Vitezslav Crhonek <vcrhonek@redhat.com>  (tiny change)
+
+       Fix memory leaks.
+       
+       * info/makedoc.c (process_one_file):
+       The memory is freed for both pointers at the end of the loop.
+       But there is one break that leaves the loop without freeing them.
+       * info/session.c (info_goto_invocation_node):
+       The value of 'default_program_name' is assigned by
+       program_name_from_file_name() function.
+       Its description says 'Return value should be freed by caller.'
+       That was not done in this case.
+
 2021-04-25  Gavin Smith  <gavinsmith0123@gmail.com>
 
        Fix memory leaks.
diff --git a/info/makedoc.c b/info/makedoc.c
index 5842cd6..9626e0d 100644
--- a/info/makedoc.c
+++ b/info/makedoc.c
@@ -1,6 +1,6 @@
 /* makedoc.c -- make doc.c and funs.h from input files.
 
-   Copyright 1993-2019 Free Software Foundation, Inc.
+   Copyright 1993-2021 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
@@ -425,7 +425,11 @@ process_one_file (char *filename, FILE *doc_stream, FILE 
*funs_stream)
 
       offset++;
       if (offset >= file_size)
-        break;
+        {
+          free (func_name);
+          free (func);
+          break;
+        }
 
       doc = xmalloc (1 + (offset - point));
       strncpy (doc, buffer + point, offset - point);
diff --git a/info/session.c b/info/session.c
index 3ca1634..d67641b 100644
--- a/info/session.c
+++ b/info/session.c
@@ -3563,6 +3563,7 @@ DECLARE_INFO_COMMAND (info_goto_invocation_node,
   if (!line)
     {
       info_abort_key (window, 0);
+      free (default_program_name);
       return;
     }
   if (*line)



reply via email to

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