view src/readline-0-003.patch @ 5579:2734b3818171

Avoid double-free with librsb (bug #58957). * src/librsb.mk: Add work-around to avoid double-free (provided by Michele Martone). * src/mingw-of-sparsersb-1-no-render.patch: Remove patch. * dist-files.mk: Remove file from list.
author Markus Mützel <markus.muetzel@gmx.de>
date Mon, 02 Nov 2020 08:55:18 +0100
parents 2b13fe9f4ef9
children
line wrap: on
line source

			   READLINE PATCH REPORT
			   =====================

Readline-Release: 8.0
Patch-ID: readline80-003

Bug-Reported-by:	HIROSE Masaaki <hirose31@gmail.com>
Bug-Reference-ID:	<CAGSOfA-RqiTe=+GsXsDKyZrrMWH4bDbXgMVVegMa6OjqC5xbnQ@mail.gmail.com>
Bug-Reference-URL:	https://lists.gnu.org/archive/html/bug-bash/2019-05/msg00038.html

Bug-Description:

Reading history entries with timestamps can result in history entries joined
by linefeeds.

diff --git "a/histfile.c" "b/histfile.c"
--- a/histfile.c	2018-06-11 09:14:52.000000000 -0400
+++ b/histfile.c	2019-05-16 15:55:57.000000000 -0400
@@ -370,7 +370,9 @@
 
   has_timestamps = HIST_TIMESTAMP_START (buffer);
-  history_multiline_entries += has_timestamps && history_write_timestamps;  
+  history_multiline_entries += has_timestamps && history_write_timestamps;
 
   /* Skip lines until we are at FROM. */
+  if (has_timestamps)
+    last_ts = buffer;
   for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++)
     if (*line_end == '\n')
@@ -381,5 +383,16 @@
 	if (HIST_TIMESTAMP_START(p) == 0)
 	  current_line++;
+	else
+	  last_ts = p;
 	line_start = p;
+	/* If we are at the last line (current_line == from) but we have
+	   timestamps (has_timestamps), then line_start points to the
+	   text of the last command, and we need to skip to its end. */
+	if (current_line >= from && has_timestamps)
+	  {
+	    for (line_end = p; line_end < bufend && *line_end != '\n'; line_end++)
+	      ;
+	    line_start = (*line_end == '\n') ? line_end + 1 : line_end;
+	  }
       }
 
diff --git "a/patchlevel" "b/patchlevel"
--- a/patchlevel	2013-11-15 08:11:11.000000000 -0500
+++ b/patchlevel	2014-03-21 08:28:40.000000000 -0400
@@ -1,3 +1,3 @@
 # Do not edit -- exists only for use by patch
 
-2
+3