ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=5dc607ecea6cba90d172a2c4306d0a4ca4b9ff49

commit 5dc607ecea6cba90d172a2c4306d0a4ca4b9ff49
Author: Andy Williams <a...@andywilliams.me>
Date:   Sun Feb 21 18:48:07 2016 +0000

    Complete the ending newline crash fix
---
 elm_code/src/lib/widget/elm_code_widget_selection.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 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 04df223..9a558ec 100644
--- a/elm_code/src/lib/widget/elm_code_widget_selection.c
+++ b/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);

-- 


Reply via email to