texinfo-commits
[Top][All Lists]
Advanced

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

[5935] don't crash for dangling dir entry


From: Gavin D. Smith
Subject: [5935] don't crash for dangling dir entry
Date: Wed, 19 Nov 2014 12:07:22 +0000

Revision: 5935
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5935
Author:   gavin
Date:     2014-11-19 12:07:16 +0000 (Wed, 19 Nov 2014)
Log Message:
-----------
don't crash for dangling dir entry

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/Makefile.am
    trunk/info/info.c
    trunk/info/t/infodir/dir

Added Paths:
-----------
    trunk/info/t/dir-dangling-entry.sh

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-11-18 17:20:25 UTC (rev 5934)
+++ trunk/ChangeLog     2014-11-19 12:07:16 UTC (rev 5935)
@@ -1,3 +1,9 @@
+2014-11-19  Gavin Smith  <address@hidden>
+
+       * info/info.c (get_initial_file) <inexact dir lookup>: Check if 
+       file referred to exists.
+       * info/t/dir-dangling-entry.sh: New test.
+
 2014-11-18  Gavin Smith  <address@hidden>
 
        * info/session.c (incremental_search): Add at most one node to 

Modified: trunk/info/Makefile.am
===================================================================
--- trunk/info/Makefile.am      2014-11-18 17:20:25 UTC (rev 5934)
+++ trunk/info/Makefile.am      2014-11-19 12:07:16 UTC (rev 5935)
@@ -105,6 +105,7 @@
        t/dir-3-menus.sh \
        t/dir-menus-sloppily.sh \
        t/where-dir-file.sh \
+       t/dir-dangling-entry.sh \
        t/spec-file-node.sh \
        t/spec-no-node.sh \
        t/spec-menu.sh \

Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c   2014-11-18 17:20:25 UTC (rev 5934)
+++ trunk/info/info.c   2014-11-19 12:07:16 UTC (rev 5935)
@@ -247,21 +247,24 @@
       entry = lookup_dir_entry ((*argv)[0], 1);
       if (entry)
         {
-          REFERENCE *copy;
-          (*argv)++; /* Advance past first remaining argument. */
-          (*argc)--;
-          /* Clear error message. */
-          free (*error);
-          *error = 0;
+          initial_file = info_find_fullpath (entry->filename, 0);
+          if (initial_file)
+            {
+              REFERENCE *copy;
+              (*argv)++; /* Advance past first remaining argument. */
+              (*argc)--;
+              /* Clear error message. */
+              free (*error);
+              *error = 0;
 
-          copy = info_copy_reference (entry);
-          initial_file = info_find_fullpath (entry->filename, 0);
-          /* Store full path, so that we find the already loaded file in
-             info_find_file, and show the full path if --where is used. */
-          free (copy->filename);
-          copy->filename = initial_file;
-          add_pointer_to_array (copy, ref_index, ref_list, ref_slots, 2);
-          return;
+              copy = info_copy_reference (entry);
+              /* Store full path, so that we find the already loaded file in
+                 info_find_file, and show the full path if --where is used. */
+              free (copy->filename);
+              copy->filename = initial_file;
+              add_pointer_to_array (copy, ref_index, ref_list, ref_slots, 2);
+              return;
+            }
         }
     }
 

Added: trunk/info/t/dir-dangling-entry.sh
===================================================================
--- trunk/info/t/dir-dangling-entry.sh                          (rev 0)
+++ trunk/info/t/dir-dangling-entry.sh  2014-11-19 12:07:16 UTC (rev 5935)
@@ -0,0 +1,32 @@
+#!/bin/sh
+# Copyright (C) 2014 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
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+srcdir=${srcdir:-.}
+. $srcdir/t/Init-test.inc
+. $t/Init-inter.inc
+
+# Try to load a dir entry refererring to a non-existing file
+
+run_ginfo non-existent
+
+printf 'Dq' >$PTY_TYPE
+
+. $t/Timeout-test.inc
+
+grep 'File: dir' $GINFO_OUTPUT
+RETVAL=$?
+
+. $t/Cleanup.inc


Property changes on: trunk/info/t/dir-dangling-entry.sh
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/info/t/infodir/dir
===================================================================
(Binary files differ)




reply via email to

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