From 1f104f80795ac63b47c1a168fb27110d6aa5bd21 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Fri, 3 Feb 2006 03:51:51 +0000 Subject: [PATCH] fix a comment in nano.h and a minor memory leak in display_string() git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3271 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ src/nano.h | 2 +- src/winio.c | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 63b8ff62..9d1e7f61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,8 @@ CVS code - fixes a potential display problem when a search moves the cursor offscreen and onto a different page. (DLR, found by Mike Frysinger) + display_string() + - Fix minor memory leak. (DLR) - doc/nano.1: - Better display the default values for quotestr. (DLR) - doc/nanorc.5: diff --git a/src/nano.h b/src/nano.h index 12105dd2..2102f3e0 100644 --- a/src/nano.h +++ b/src/nano.h @@ -590,7 +590,7 @@ typedef struct rcoption { * counting the blank lines at their ends. */ #define MAX_SEARCH_HISTORY 100 -/* The maximum number of bytes we read from a file at one time. */ +/* The maximum number of bytes we read into a buffer at one time. */ #define MAX_BUF_SIZE 128 #endif /* !NANO_H */ diff --git a/src/winio.c b/src/winio.c index 08faf5b6..4a3c8a0a 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1791,8 +1791,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool /* The string we return. */ size_t index; /* Current position in converted. */ - - char *buf_mb = charalloc(mb_cur_max()); + char *buf_mb; int buf_mb_len; /* If dollars is TRUE, make room for the "$" at the end of the @@ -1803,6 +1802,8 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool if (len == 0) return mallocstrcpy(NULL, ""); + buf_mb = charalloc(mb_cur_max()); + start_index = actual_x(buf, start_col); column = strnlenpt(buf, start_index);