From bd9c9343ebe6e0c854e3a96d38139f54845c47bf Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 6 Jun 2003 23:54:20 +0000 Subject: [PATCH] * view.c (get_byte): Fix off-by-one error. Found by Valgrind. --- src/ChangeLog | 2 ++ src/view.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index dd7a59197..71a0f5084 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2003-06-06 Pavel Roskin + * view.c (get_byte): Fix off-by-one error. Found by Valgrind. + * command.c (command_new): Fix memory leak. * subshell.c (exit_subshell): Free pty_buffer. diff --git a/src/view.c b/src/view.c index 9c48a6dac..2b85d0883 100644 --- a/src/view.c +++ b/src/view.c @@ -336,7 +336,7 @@ get_byte (WView *view, unsigned int byte_index) } view->blocks = page; } - if (byte_index > view->bytes_read) { + if (byte_index >= view->bytes_read) { return -1; } else return view->block_ptr[page - 1].data[offset];