diff options
author | Andy Williams <andy@andywilliams.me> | 2016-02-21 18:48:07 +0000 |
---|---|---|
committer | Andy Williams <andy@andywilliams.me> | 2016-02-21 18:48:07 +0000 |
commit | 9b491f8efac18f4e0d9fba9d6b9e4fef8bb6da28 (patch) | |
tree | 46d1f53fc6f3d9381d09fe2dfeb08c1a7d4dc680 | |
parent | 0bcd87a2af98b9e0e2c89d826c955f8378d1ae3f (diff) | |
download | efl-9b491f8efac18f4e0d9fba9d6b9e4fef8bb6da28.tar.gz |
Complete the ending newline crash fix
-rw-r--r-- | legacy/elm_code/src/lib/widget/elm_code_widget_selection.c | 20 |
1 files changed, 16 insertions, 4 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 04df2232b4..9a558ecc6b 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 @@ -163,10 +163,22 @@ _elm_code_widget_selection_delete_single(Elm_Code_Widget *widget, Elm_Code_Widge end = elm_code_widget_line_text_position_for_column_get(widget, line, selection->end_col); length = line->length - (end - start + 1); - content = malloc(sizeof(char) * length); - strncpy(content, old, start); - strncpy(content + start, old + end + 1, - old_length - (end + 1)); + if (end == line->length) + { + length = line->length - (end - start); + + content = malloc(sizeof(char) * length); + strncpy(content, old, start); + } + else + { + length = line->length - (end - start + 1); + + content = malloc(sizeof(char) * length); + strncpy(content, old, start); + strncpy(content + start, old + end + 1, + old_length - (end + 1)); + } elm_code_line_text_set(line, content, length); free(content); free(selection); |