diff -Naur a/readline-6.2/histexpand.c b/readline-6.2/histexpand.c
--- a/readline-6.2/histexpand.c	2010-07-26 03:11:05.000000000 +0530
+++ b/readline-6.2/histexpand.c	2013-12-02 14:36:48.000000000 +0530
@@ -272,7 +272,9 @@
       if (local_index == 0 || substring_okay)
 	{
 	  entry = current_history ();
-	  history_offset = history_length;
+	  if (entry == 0)
+        return 0;
+    history_offset = history_length;
 	
 	  /* If this was a substring search, then remember the
 	     string that we matched for word substitution. */
diff -Naur a/readline-6.2/search.c b/readline-6.2/search.c
--- a/readline-6.2/search.c	2010-07-26 02:59:05.000000000 +0530
+++ b/readline-6.2/search.c	2013-12-02 14:42:22.000000000 +0530
@@ -1,4 +1,4 @@
-/* search.c - code for non-incremental searching in emacs and vi modes. */
+et* search.c - code for non-incremental searching in emacs and vi modes. */
 
 /* Copyright (C) 1992-2009 Free Software Foundation, Inc.
 
@@ -170,6 +170,8 @@
   oldpos = where_history ();
   history_set_pos (noninc_history_pos);
   entry = current_history ();
+  if (entry == 0)
+     return 0;
 #if defined (VI_MODE)
   if (rl_editing_mode != vi_mode)
 #endif
@@ -471,6 +473,8 @@
       oldpos = where_history ();
       history_set_pos (rl_history_search_pos);
       temp = current_history ();
+      if (temp == 0)
+          return 1;
       history_set_pos (oldpos);
 
       /* Don't find multiple instances of the same line. */
