bug-readline
[Top][All Lists]
Advanced

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

[Bug-readline] a fix for rl_do_undo in readline-6.3-rc2


From: Hiroo Hayashi
Subject: [Bug-readline] a fix for rl_do_undo in readline-6.3-rc2
Date: Sun, 23 Feb 2014 00:08:37 +0900

Hi

The following change was added in 6.3-rc2.
current_history() may return NULL and results in a segmentation fault.

--- readline-6.3-beta/undo.c    2012-02-05 06:32:22.000000000 +0900
+++ readline-6.3-rc2/undo.c     2013-12-29 08:27:22.000000000 +0900
@@ -178,6 +178,7 @@
 {
   UNDO_LIST *release;
   int waiting_for_begin, start, end;
+  HIST_ENTRY *cur, *temp;

 #define TRANS(i) ((i) == -1 ? rl_point : ((i) == -2 ? rl_end : (i)))

@@ -232,6 +233,18 @@

       release = rl_undo_list;
       rl_undo_list = rl_undo_list->next;
+
+      /* If we are editing a history entry, make sure the change is replicated
+        in the history entry's line */
+      cur = current_history ();
+      if ((UNDO_LIST *)cur->data == release)
+       {
+         temp = replace_history_entry (where_history (), rl_line_buffer, 
(histdata_t)rl_undo_list);
+         xfree (temp->line);
+         FREE (temp->timestamp);
+         xfree (temp);
+       }
+
       replace_history_data (-1, (histdata_t *)release, (histdata_t 
*)rl_undo_list);

       xfree (release);
-------------------

Here is a patch.

--- undo.c-dist 2013-12-29 08:27:22.000000000 +0900
+++ undo.c      2014-02-22 23:31:07.967422200 +0900
@@ -237,7 +237,7 @@
       /* If we are editing a history entry, make sure the change is replicated
         in the history entry's line */
       cur = current_history ();
-      if ((UNDO_LIST *)cur->data == release)
+      if (cur != NULL && (UNDO_LIST *)cur->data == release)
        {
          temp = replace_history_entry (where_history (), rl_line_buffer, 
(histdata_t)rl_undo_list);
          xfree (temp->line);

-- 
Hiroo Hayashi




reply via email to

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