diff options
author | Andy Williams <andy@andywilliams.me> | 2016-02-21 18:03:29 +0000 |
---|---|---|
committer | Andy Williams <andy@andywilliams.me> | 2016-02-21 18:03:29 +0000 |
commit | fcf2318d2bec4b3233138c10505c5ab176b21863 (patch) | |
tree | 65619f1c976ecc2cae8eed963a1ca8cd21f215ba | |
parent | 3c80041cdd493f3b3d00c27f7819b0470ad12c05 (diff) | |
download | efl-fcf2318d2bec4b3233138c10505c5ab176b21863.tar.gz |
[editor] Fix crash when deleting selections
If the selection ended in the carriage return the
editor could craash.
@fix
-rw-r--r-- | legacy/elm_code/src/lib/widget/elm_code_widget_selection.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/legacy/elm_code/src/lib/widget/elm_code_widget_selection.c b/legacy/elm_code/src/lib/widget/elm_code_widget_selection.c index 6479123ff5..04df2232b4 100644 --- a/legacy/elm_code/src/lib/widget/elm_code_widget_selection.c +++ b/legacy/elm_code/src/lib/widget/elm_code_widget_selection.c @@ -193,11 +193,20 @@ _elm_code_widget_selection_delete_multi(Elm_Code_Widget *widget, Elm_Code_Widget last = elm_code_line_text_get(line, &last_length); end = elm_code_widget_line_text_position_for_column_get(widget, line, selection->end_col); - length = start + last_length - (end + 1); - content = malloc(sizeof(char) * length); - strncpy(content, first, start); - strncpy(content + start, last + end + 1, - last_length - (end + 1)); + if (last_length == end) + { + length = start + last_length - end; + content = malloc(sizeof(char) * length); + strncpy(content, first, start); + } + else + { + length = start + last_length - (end + 1); + content = malloc(sizeof(char) * length); + strncpy(content, first, start); + + strncpy(content + start, last + end + 1, last_length - (end + 1)); + } for (i = line->number; i > selection->start_line; i--) elm_code_file_line_remove(pd->code->file, i); |