[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5783] fix some memory leaks
From: |
Gavin D. Smith |
Subject: |
[5783] fix some memory leaks |
Date: |
Mon, 25 Aug 2014 19:45:26 +0000 |
Revision: 5783
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5783
Author: gavin
Date: 2014-08-25 19:45:25 +0000 (Mon, 25 Aug 2014)
Log Message:
-----------
fix some memory leaks
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/info-utils.c
trunk/info/info.c
trunk/info/session.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-08-25 17:26:55 UTC (rev 5782)
+++ trunk/ChangeLog 2014-08-25 19:45:25 UTC (rev 5783)
@@ -3,6 +3,18 @@
* info/dir.c (insert_text_into_node): Include terminating null byte
from node contents.
+ * info/info-utils.c (scan_node_contents): Free match list before
+ returning.
+ * info/info.c (main, initial_file): Make initial_file file-level
+ variable.
+ (get_initial_file): Set initial_file variable instead of returning a
+ value.
+ (add_initial_nodes): Use info_reference_free instead of free on
+ REFERENCE variables. Duplicate arguments to info_new_reference so we
+ can free them.
+ * info/session.c (info_follow_menus): Always free initial_node
+ argument before returning.
+
2014-08-25 Gavin Smith <address@hidden>
* info/display.c (find_diff): Add braces round "if" command.
Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c 2014-08-25 17:26:55 UTC (rev 5782)
+++ trunk/info/info-utils.c 2014-08-25 19:45:25 UTC (rev 5783)
@@ -1728,6 +1728,8 @@
/* Free resources used in character encoding conversion. */
close_conversion ();
+
+ free (matches);
node->references = refs;
Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c 2014-08-25 17:26:55 UTC (rev 5782)
+++ trunk/info/info.c 2014-08-25 19:45:25 UTC (rev 5783)
@@ -54,6 +54,9 @@
/* Non-zero means print a short description of the options. */
static int print_help_p = 0;
+/* Name of file to start session with. */
+static char *initial_file = 0;
+
/* Array of the names of nodes that the user specified with "--node" on the
command line. */
static char **user_nodenames = NULL;
@@ -160,12 +163,12 @@
static void init_messages (void);
-/* Get the initial Info file, either by following menus from "(dir)Top",
- or what the user specifed with values in filename. */
-static char *
+/* Set INITIAL_FILE to the name of the initial Info file, either by
+ following menus from "(dir)Top", or what the user specifed with
+ values in FILENAME. */
+static void
get_initial_file (char *filename, int *argc, char ***argv, char **error)
{
- char *initial_file = 0; /* First file loaded by Info. */
REFERENCE *entry;
/* If there are any more arguments, the initial file is the
@@ -192,7 +195,7 @@
entry->filename = initial_file;
add_pointer_to_array (info_copy_reference (entry),
ref_index, ref_list, ref_slots, 2);
- return initial_file;
+ return;
}
}
}
@@ -208,7 +211,7 @@
*error = filesys_error_string (filename, filesys_error_number);
}
else
- return initial_file;
+ return;
}
/* File name lookup. */
@@ -221,7 +224,7 @@
{
(*argv)++; /* Advance past first remaining argument. */
(*argc)--;
- return initial_file;
+ return;
}
else
asprintf (error, _("No menu item `%s' in node `%s'."),
@@ -244,7 +247,7 @@
ref_index, ref_list, ref_slots, 2);
initial_file = MANPAGE_FILE_BUFFER_NAME;
- return initial_file;
+ return;
}
}
@@ -266,13 +269,13 @@
entry->filename = initial_file;
add_pointer_to_array (info_copy_reference (entry),
ref_index, ref_list, ref_slots, 2);
- return initial_file;
+ return;
}
}
/* Otherwise, we want the dir node. The only node to be displayed
or output will be "Top". */
- return 0;
+ return;
}
/* Expand list of nodes to be loaded. */
@@ -288,7 +291,7 @@
if (ref_index > 0)
{
/* Discard a dir entry that was found. */
- free (ref_list[0]);
+ info_reference_free (ref_list[0]);
ref_index = 0;
}
@@ -333,7 +336,7 @@
if (ref_index > 0)
{
/* Discard a dir entry that was found. */
- free (ref_list[0]);
+ info_reference_free (ref_list[0]);
ref_index = 0;
}
@@ -375,7 +378,8 @@
if (ref_index == 0)
add_pointer_to_array
- (info_new_reference (initial_file->fullpath, "Top"),
+ (info_new_reference (xstrdup (initial_file->fullpath),
+ xstrdup ("Top")),
ref_index, ref_list, ref_slots, 2);
initial_node = info_get_node_with_defaults (ref_list[0]->filename,
@@ -388,7 +392,7 @@
{
argv += argc; argc = 0;
- free (ref_list[0]);
+ info_reference_free (ref_list[0]);
ref_list[0] = info_new_reference (node_via_menus->fullpath,
node_via_menus->nodename);
free (node_via_menus);
@@ -424,7 +428,7 @@
argv += argc; argc = 0;
free (*error); *error = 0;
- free (ref_list[0]);
+ info_reference_free (ref_list[0]);
ref_list[0] = info_copy_reference (nearest);
}
}
@@ -441,7 +445,7 @@
{
argv += argc; argc = 0;
- free (ref_list[0]);
+ info_reference_free (ref_list[0]);
ref_list[0] = info_new_reference (node_via_menus->fullpath,
node_via_menus->nodename);
free (node_via_menus);
@@ -545,7 +549,6 @@
{
int getopt_long_index; /* Index returned by getopt_long (). */
char *init_file = 0; /* Name of init file specified. */
- char *initial_file = 0; /* File to start session with. */
FILE_BUFFER *initial_fb = 0; /* File to start session with. */
char *error = 0; /* Error message to display in mini-buffer. */
@@ -811,7 +814,7 @@
}
else
{
- initial_file = get_initial_file (user_filename, &argc, &argv, &error);
+ get_initial_file (user_filename, &argc, &argv, &error);
/* If the user specified `--index-search=STRING',
start the info session in the node corresponding
Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c 2014-08-25 17:26:55 UTC (rev 5782)
+++ trunk/info/session.c 2014-08-25 19:45:25 UTC (rev 5783)
@@ -2740,7 +2740,13 @@
asprintf (error, _("No menu in node `%s'."),
node_printed_rep (initial_node));
debug (3, ("no menu found"));
- return strict ? 0 : initial_node;
+ if (!strict)
+ return initial_node;
+ else
+ {
+ free (initial_node);
+ return 0;
+ }
}
/* Find the specified menu item. */
@@ -2753,7 +2759,13 @@
asprintf (error, _("No menu item `%s' in node `%s'."),
arg, node_printed_rep (initial_node));
debug (3, ("no entry found"));
- return strict ? 0 : initial_node;
+ if (!strict)
+ return initial_node;
+ else
+ {
+ free (initial_node);
+ return 0;
+ }
}
debug (3, ("entry: %s, %s", entry->filename, entry->nodename));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5783] fix some memory leaks,
Gavin D. Smith <=