[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7264] info fix crash
From: |
gavinsmith0123 |
Subject: |
[7264] info fix crash |
Date: |
Sun, 17 Jul 2016 16:44:53 +0000 (UTC) |
Revision: 7264
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7264
Author: gavin
Date: 2016-07-17 16:44:53 +0000 (Sun, 17 Jul 2016)
Log Message:
-----------
info fix crash
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/indices.c
trunk/info/nodes.c
trunk/info/nodes.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2016-07-16 19:52:28 UTC (rev 7263)
+++ trunk/ChangeLog 2016-07-17 16:44:53 UTC (rev 7264)
@@ -1,3 +1,11 @@
+2016-07-17 Gavin Smith <address@hidden>
+
+ * info/indices.c (apropos_in_all_indices): Only free file buffer
+ if we had to load it. Otherwise the file buffer could still be
+ referenced. Fixes crash reported by "address@hidden".
+ * info/nodes.c (check_loaded_file): Function split out from
+ info_find_file.
+
2016-07-16 Gavin Smith <address@hidden>
* dco/texinfo-tex-test.texi (Test of auxiliary files): Add test
Modified: trunk/info/indices.c
===================================================================
--- trunk/info/indices.c 2016-07-16 19:52:28 UTC (rev 7263)
+++ trunk/info/indices.c 2016-07-17 16:44:53 UTC (rev 7264)
@@ -558,7 +558,7 @@
for (dir_index = 0; dir_menu[dir_index]; dir_index++)
{
REFERENCE **this_index, *this_item;
- FILE_BUFFER *this_fb;
+ FILE_BUFFER *this_fb, *loaded_file = 0;
this_item = dir_menu[dir_index];
if (!this_item->filename)
@@ -574,11 +574,14 @@
if (i < dir_index)
continue;
- this_fb = info_find_file (this_item->filename);
+ this_fb = check_loaded_file (this_item->filename);
if (!this_fb)
- continue;
+ this_fb = loaded_file = info_find_file (this_item->filename);
+ if (!this_fb)
+ continue; /* Couldn't load file. */
+
if (this_fb && inform)
message_in_echo_area (_("Scanning indices of '%s'..."),
this_item->filename);
@@ -602,9 +605,16 @@
free (old_indices);
}
}
- /* Try to avoid running out of memory */
- free (this_fb->contents);
- this_fb->contents = NULL;
+
+ /* Try to avoid running out of memory by not loading all of the
+ Info files on the system into memory. This is risky because we
+ may have a pointer into the file buffer, so only free the contents
+ if we have just loaded the file. */
+ if (loaded_file)
+ {
+ free (loaded_file->contents);
+ loaded_file->contents = NULL;
+ }
}
/* Build a list of the references which contain SEARCH_STRING. */
Modified: trunk/info/nodes.c
===================================================================
--- trunk/info/nodes.c 2016-07-16 19:52:28 UTC (rev 7263)
+++ trunk/info/nodes.c 2016-07-17 16:44:53 UTC (rev 7264)
@@ -544,24 +544,17 @@
static void forget_info_file (FILE_BUFFER *file_buffer);
static void info_reload_file_buffer_contents (FILE_BUFFER *fb);
-/* Locate the file named by FILENAME, and return the information structure
- describing this file. The file may appear in our list of loaded files
- already, or it may not. If it does not already appear, find the file,
- and add it to the list of loaded files. If the file cannot be found,
- return a NULL FILE_BUFFER *. */
+/* Try to find a file in our list of already loaded files. */
FILE_BUFFER *
-info_find_file (char *filename)
+check_loaded_file (char *filename)
{
- int i;
+ int is_fullpath, i;
FILE_BUFFER *file_buffer;
- char *fullpath;
- int is_fullpath;
/* If full path to the file has been given, we must find it exactly. */
is_fullpath = IS_ABSOLUTE (filename)
|| filename[0] == '.' && IS_SLASH(filename[1]);
- /* First try to find the file in our list of already loaded files. */
if (info_loaded_files)
{
for (i = 0; (file_buffer = info_loaded_files[i]); i++)
@@ -601,11 +594,31 @@
return file_buffer;
}
}
+ return 0;
+}
+/* Locate the file named by FILENAME, and return the information structure
+ describing this file. The file may appear in our list of loaded files
+ already, or it may not. If it does not already appear, find the file,
+ and add it to the list of loaded files. If the file cannot be found,
+ return a NULL FILE_BUFFER *. */
+FILE_BUFFER *
+info_find_file (char *filename)
+{
+ FILE_BUFFER *file_buffer;
+ char *fullpath;
+ int is_fullpath;
+
+ file_buffer = check_loaded_file (filename);
+ if (file_buffer)
+ return file_buffer;
+
/* The file wasn't loaded. Try to load it now. */
/* Get the full pathname of this file, as known by the info system.
That is to say, search along INFOPATH and expand tildes, etc. */
+ is_fullpath = IS_ABSOLUTE (filename)
+ || filename[0] == '.' && IS_SLASH(filename[1]);
if (!is_fullpath)
fullpath = info_find_fullpath (filename, 0);
else
Modified: trunk/info/nodes.h
===================================================================
--- trunk/info/nodes.h 2016-07-16 19:52:28 UTC (rev 7263)
+++ trunk/info/nodes.h 2016-07-17 16:44:53 UTC (rev 7264)
@@ -141,6 +141,8 @@
return a NULL FILE_BUFFER *. */
FILE_BUFFER *info_find_file (char *filename);
+FILE_BUFFER *check_loaded_file (char *filename);
+
FILE_BUFFER *info_find_subfile (char *filename);
TAG *info_create_tag (void);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7264] info fix crash,
gavinsmith0123 <=