diff --git a/ChangeLog b/ChangeLog
index 3c21ac70ecb289ac63c474367f4f54598842d0a7..de84318aef7911a123305e85cea6e456f984d075 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,10 @@ CVS code -
 - nano.c:
   do_delete()
 	- Tweak for efficiency. (David Benbennick)
+  do_verbatim_kbinput()
+	- Use size_t's instead of ints for the get_verbatim_kbinput()
+	  call and the loop that ungetch()es its returned int*,
+	  respectively. (DLR)
 - proto.h:
 	- Remove unused add_marked_sameline() prototype. (DLR)
 - rcfile.c:
@@ -39,6 +43,14 @@ CVS code -
 	- Refactor the output in the DEBUG #ifdef.  It didn't work
 	  properly ever since this function was changed to use an int*
 	  instead of a char*. (DLR)
+	- Change kbinput_len from an int* to a size_t*, since it should
+	  never be negative. (DLR)
+	- When reading characters from input, properly reallocate
+	  verbatim_kbinput via (int*)nrealloc() instead of an uncast
+	  realloc(). (DLR)
+  get_escape_seq_kbinput()
+	- Change escape_seq_len from an int to a size_t, since it should
+	  never be negative. (DLR)
   edit_refresh()
 	- Remove apparently unneeded leaveok() calls. (David Benbennick)
 - nano.texi:
diff --git a/src/nano.c b/src/nano.c
index 4a11b1b4077dc801b132e81e64830778d22dc283..6ea3c359fac25a1f4557896e8aec3c3309b298c7 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -998,8 +998,8 @@ void do_char(char ch)
 int do_verbatim_input(void)
 {
     int *verbatim_kbinput;	/* Used to hold verbatim input. */
-    int verbatim_len;		/* Length of verbatim input. */
-    int i;
+    size_t verbatim_len;	/* Length of verbatim input. */
+    size_t i;
 
     statusbar(_("Verbatim input"));
     verbatim_kbinput = get_verbatim_kbinput(edit, &verbatim_len, 1);
diff --git a/src/proto.h b/src/proto.h
index 11eec4ab6cbe51e79ff9b6ad768ba9ba3094b112..489ee7dc9f64b4bf8d22e3b1addeaf65c4e52b72 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -452,12 +452,12 @@ int check_wildcard_match(const char *text, const char *pattern);
 
 /* Public functions in winio.c */
 int get_kbinput(WINDOW *win, int *meta_key);
-int *get_verbatim_kbinput(WINDOW *win, int *kbinput_len, int
+int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len, int
 	allow_ascii);
 int get_ignored_kbinput(WINDOW *win);
 int get_accepted_kbinput(WINDOW *win, int kbinput, int *meta_key);
 int get_ascii_kbinput(WINDOW *win, int kbinput);
-int get_escape_seq_kbinput(WINDOW *win, int *escape_seq, int
+int get_escape_seq_kbinput(WINDOW *win, int *escape_seq, size_t
 	escape_seq_len);
 int get_escape_seq_abcd(int kbinput);
 int get_mouseinput(int *mouse_x, int *mouse_y, int shortcut);
diff --git a/src/winio.c b/src/winio.c
index a4cfdf131b2b55bb5361a62dfe004015b6be9086..dd56cf4e159478f039f7a57861d74422611b52a2 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -65,7 +65,7 @@ int get_kbinput(WINDOW *win, int *meta_key)
 /* Read in a string of input characters (e.g. an escape sequence)
  * verbatim, and return the length of the string in kbinput_len.  Assume
  * nodelay(win) is FALSE. */
-int *get_verbatim_kbinput(WINDOW *win, int *kbinput_len, int
+int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len, int
 	allow_ascii)
 {
     int kbinput, *verbatim_kbinput;
@@ -101,7 +101,7 @@ int *get_verbatim_kbinput(WINDOW *win, int *kbinput_len, int
 #endif
 	while ((kbinput = wgetch(win)) != ERR) {
 	    (*kbinput_len)++;
-	    verbatim_kbinput = realloc(verbatim_kbinput, *kbinput_len * sizeof(int));
+	    verbatim_kbinput = (int *)nrealloc(verbatim_kbinput, *kbinput_len * sizeof(int));
 	    verbatim_kbinput[*kbinput_len - 1] = kbinput;
 #ifdef DEBUG
 	    fprintf(stderr, "get_verbatim_kbinput(): kbinput = %d\n", kbinput);
@@ -196,7 +196,8 @@ int get_accepted_kbinput(WINDOW *win, int kbinput, int *meta_key)
 		 * Hemel. */
 		case '[':
 		{
-		    int old_kbinput = kbinput, *escape_seq, escape_seq_len;
+		    int old_kbinput = kbinput, *escape_seq;
+		    size_t escape_seq_len;
 		    nodelay(win, TRUE);
 		    kbinput = wgetch(win);
 		    switch (kbinput) {
@@ -371,7 +372,7 @@ int get_ascii_kbinput(WINDOW *win, int kbinput)
  *   omitted.  (Same as above.)
  * - The Hurd console has no escape sequences for F11, F12, F13, or
  *   F14. */
-int get_escape_seq_kbinput(WINDOW *win, int *escape_seq, int
+int get_escape_seq_kbinput(WINDOW *win, int *escape_seq, size_t
 	escape_seq_len)
 {
     int kbinput = ERR;