texinfo-commits
[Top][All Lists]
Advanced

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

[5794] don't crash on empty search string


From: Gavin D. Smith
Subject: [5794] don't crash on empty search string
Date: Mon, 01 Sep 2014 15:17:33 +0000

Revision: 5794
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5794
Author:   gavin
Date:     2014-09-01 15:17:32 +0000 (Mon, 01 Sep 2014)
Log Message:
-----------
don't crash on empty search string

Modified Paths:
--------------
    trunk/info/Makefile.am
    trunk/info/session.c

Added Paths:
-----------
    trunk/info/t/search-empty.sh

Modified: trunk/info/Makefile.am
===================================================================
--- trunk/info/Makefile.am      2014-09-01 15:03:41 UTC (rev 5793)
+++ trunk/info/Makefile.am      2014-09-01 15:17:32 UTC (rev 5794)
@@ -121,6 +121,7 @@
        t/relative-reference.sh \
        t/resize-in-completions.sh \
        t/search-skip-screen.sh \
+       t/search-empty.sh \
        t/inc-sea-forward.sh \
        t/inc-sea-forward-nonregex.sh \
        t/inc-sea-insensitive.sh \

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2014-09-01 15:03:41 UTC (rev 5793)
+++ trunk/info/session.c        2014-09-01 15:17:32 UTC (rev 5794)
@@ -3483,7 +3483,6 @@
 static void info_search_1 (WINDOW *window, int count, int case_sensitive);
 
 static char *search_string = NULL;
-static int search_string_size = 0;
 static int isearch_is_active = 0;
 
 static int last_search_direction = 0;
@@ -3847,26 +3846,19 @@
   line = info_read_in_echo_area (prompt);
   free (prompt);
 
-  if (!line)
+  if (!line || !*line)
     return 0;
 
-  if (*line)
+  if (mbslen (line) < min_search_length)
     {
-      if (strlen (line) + 1 > (unsigned int) search_string_size)
-        search_string =
-          xrealloc (search_string,
-                    (search_string_size += 50 + strlen (line)));
-
-      strcpy (search_string, line);
-      free (line);
-    }
-
-  if (mbslen (search_string) < min_search_length)
-    {
       info_error ("%s", _("Search string too short"));
+      free (line);
       return 0;
     }
 
+  free (search_string);
+  search_string = line;
+
   return 1;
 }
 

Added: trunk/info/t/search-empty.sh
===================================================================
--- trunk/info/t/search-empty.sh                                (rev 0)
+++ trunk/info/t/search-empty.sh        2014-09-01 15:17:32 UTC (rev 5794)
@@ -0,0 +1,27 @@
+#!/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
+
+run_ginfo -f intera
+# Search without specifying a search string, and check we don't crash.
+printf 's\rq' >$PTY_TYPE
+
+. $t/Timeout-test.inc
+. $t/Cleanup.inc
+


Property changes on: trunk/info/t/search-empty.sh
___________________________________________________________________
Added: svn:executable
   + *




reply via email to

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