ajwillia-ms pushed a commit to branch master. http://git.enlightenment.org/tools/edi.git/commit/?id=63e5ce4e8f1a74356b367a0c72826711ddab3622
commit 63e5ce4e8f1a74356b367a0c72826711ddab3622 Author: Andy Williams <[email protected]> Date: Tue May 5 21:40:22 2015 +0100 editor: Fix crash when pasting multi line Not tracking length correctly so depending on what else is in memory we could overrun the buffer --- elm_code/src/lib/widget/elm_code_widget_selection.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/elm_code/src/lib/widget/elm_code_widget_selection.c b/elm_code/src/lib/widget/elm_code_widget_selection.c index 473d999..440833c 100644 --- a/elm_code/src/lib/widget/elm_code_widget_selection.c +++ b/elm_code/src/lib/widget/elm_code_widget_selection.c @@ -308,7 +308,7 @@ _selection_paste_multi(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd, Elm_Co unsigned int col, unsigned int row, const char *text, unsigned int len) { Elm_Code_Line *line; - unsigned int position, newrow; + unsigned int position, newrow, remain; int nlpos; char *ptr; @@ -318,14 +318,16 @@ _selection_paste_multi(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd, Elm_Co newrow = row; ptr = (char *)text; - while ((nlpos = elm_code_text_newlinenpos(ptr, len)) != ELM_CODE_TEXT_NOT_FOUND) + remain = len; + while ((nlpos = elm_code_text_newlinenpos(ptr, remain)) != ELM_CODE_TEXT_NOT_FOUND) { if (newrow == row) _selection_paste_single(widget, pd, code, col, row, text, nlpos); else elm_code_file_line_insert(code->file, newrow, ptr, nlpos, NULL); - ptr += nlpos + 1; // TODO make this adapt to windows lengths (length param to newlinenpos) + remain -= nlpos + 1; // TODO make this adapt to windows lengths (length param to newlinenpos) + ptr += nlpos + 1; newrow++; } --
