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);