forked from enlightenment/efl
editor: Fix crash when pasting multi line
Not tracking length correctly so depending on what else is in memory we could overrun the buffer
This commit is contained in:
parent
d2f14a82b7
commit
ee9cec7ddd
|
@ -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++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue