diff src/cmdhist.c @ 19517:738a4fe2c8c5 v8.2.0316

patch 8.2.0316: ex_getln.c code has insufficient test coverage Commit: https://github.com/vim/vim/commit/8d588ccee57390aa01c2395fc599bbe6506ee13a Author: Bram Moolenaar <Bram@vim.org> Date: Tue Feb 25 21:47:45 2020 +0100 patch 8.2.0316: ex_getln.c code has insufficient test coverage Problem: ex_getln.c code has insufficient test coverage. Solution: Add more tests. Fix a problem. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5693)
author Bram Moolenaar <Bram@vim.org>
date Tue, 25 Feb 2020 22:00:04 +0100
parents 04245f071792
children 4dfd00f481fb
line wrap: on
line diff
--- a/src/cmdhist.c
+++ b/src/cmdhist.c
@@ -389,7 +389,7 @@ calc_hist_idx(int histype, int num)
 		i += hislen;
 		wrapped = TRUE;
 	    }
-	if (hist[i].hisnum == num && hist[i].hisstr != NULL)
+	if (i >= 0 && hist[i].hisnum == num && hist[i].hisstr != NULL)
 	    return i;
     }
     else if (-num <= hislen)