+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>
* 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.
complete_len = strlen(answer);
if (complete_len > 0) {
- answer = mallocstrcpy(answer,
- get_history_completion(history_list,
- answer, complete_len));
+ answer = get_history_completion(history_list,
+ answer, complete_len);
statusbar_x = strlen(answer);
}
} else
bool find_bracket_match(bool reverse, const char *bracket_set);
void do_find_bracket(void);
#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
#ifndef DISABLE_HISTORIES
* 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
* 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);
if (p != NULL) {
*h = p;
- return (*h)->data;
+ return mallocstrcpy(s, (*h)->data);
}
/* Search the history list from the top to the current position
if (p != NULL) {
*h = p;
- return (*h)->data;
+ return mallocstrcpy(s, (*h)->data);
}
}