Commit e86dc038 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

Avoiding a memory leak when tabbing on a string that doesn't occur in the

history.  This fixes Savannah bug #47124 reported by Mike Frysinger.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5653 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 11 additions and 7 deletions
+11 -7
2016-02-20 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (get_history_completion): Avoid leaking memory
when tabbing on a string that does not occur in the history.
This fixes Savannah bug #47124 reported by Mike Frysinger.
2016-02-18 Benno Schulenberg <bensberg@justemail.net> 2016-02-18 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (do_replace_loop), src/text.c (do_int_spell_fix), * src/search.c (do_replace_loop), src/text.c (do_int_spell_fix),
src/winio.c (edit_refresh): Fix Savannah bug #47127 the proper way. src/winio.c (edit_refresh): Fix Savannah bug #47127 the proper way.
......
...@@ -616,9 +616,8 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs, ...@@ -616,9 +616,8 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
complete_len = strlen(answer); complete_len = strlen(answer);
if (complete_len > 0) { if (complete_len > 0) {
answer = mallocstrcpy(answer, answer = get_history_completion(history_list,
get_history_completion(history_list, answer, complete_len);
answer, complete_len));
statusbar_x = strlen(answer); statusbar_x = strlen(answer);
} }
} else } else
......
...@@ -623,7 +623,7 @@ void do_gotolinecolumn_void(void); ...@@ -623,7 +623,7 @@ void do_gotolinecolumn_void(void);
bool find_bracket_match(bool reverse, const char *bracket_set); bool find_bracket_match(bool reverse, const char *bracket_set);
void do_find_bracket(void); void do_find_bracket(void);
#ifndef DISABLE_TABCOMP #ifndef DISABLE_TABCOMP
char *get_history_completion(filestruct **h, const char *s, size_t len); char *get_history_completion(filestruct **h, char *s, size_t len);
#endif #endif
#endif #endif
#ifndef DISABLE_HISTORIES #ifndef DISABLE_HISTORIES
......
...@@ -1351,7 +1351,7 @@ void get_history_older_void(void) ...@@ -1351,7 +1351,7 @@ void get_history_older_void(void)
* looking at only the first len characters of s, and return that * looking at only the first len characters of s, and return that
* string. If there isn't one, or if len is 0, don't move h and return * string. If there isn't one, or if len is 0, don't move h and return
* s. */ * s. */
char *get_history_completion(filestruct **h, const char *s, size_t len) char *get_history_completion(filestruct **h, char *s, size_t len)
{ {
assert(s != NULL); assert(s != NULL);
...@@ -1380,7 +1380,7 @@ char *get_history_completion(filestruct **h, const char *s, size_t len) ...@@ -1380,7 +1380,7 @@ char *get_history_completion(filestruct **h, const char *s, size_t len)
if (p != NULL) { if (p != NULL) {
*h = p; *h = p;
return (*h)->data; return mallocstrcpy(s, (*h)->data);
} }
/* Search the history list from the top to the current position /* Search the history list from the top to the current position
...@@ -1392,7 +1392,7 @@ char *get_history_completion(filestruct **h, const char *s, size_t len) ...@@ -1392,7 +1392,7 @@ char *get_history_completion(filestruct **h, const char *s, size_t len)
if (p != NULL) { if (p != NULL) {
*h = p; *h = p;
return (*h)->data; return mallocstrcpy(s, (*h)->data);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment