ajwillia-ms pushed a commit to branch master. http://git.enlightenment.org/tools/edi.git/commit/?id=5cbab1fa729f5401e71009d9b1f3d5b0af1b9508
commit 5cbab1fa729f5401e71009d9b1f3d5b0af1b9508 Author: Andy Williams <a...@andywilliams.me> Date: Mon May 18 15:49:24 2015 +0100 editor: fix nulls being appended to lines Should resolve issues with nulls being inserted and also crashes on pasting into a selection --- elm_code/src/lib/elm_code_text.c | 6 +++--- elm_code/src/lib/widget/elm_code_widget_selection.c | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/elm_code/src/lib/elm_code_text.c b/elm_code/src/lib/elm_code_text.c index 2ae3432..8d779a7 100644 --- a/elm_code/src/lib/elm_code_text.c +++ b/elm_code/src/lib/elm_code_text.c @@ -32,7 +32,7 @@ elm_code_line_text_set(Elm_Code_Line *line, const char *chars, unsigned int leng if (line->modified) free(line->modified); - newtext = malloc(sizeof(char) * length + 1); + newtext = malloc(sizeof(char) * length); strncpy(newtext, chars, length); line->modified = newtext; line->length = length; @@ -144,7 +144,7 @@ elm_code_line_text_insert(Elm_Code_Line *line, unsigned int position, const char if (!line) return; - inserted = malloc(sizeof(char) * line->length + length + 1); + inserted = malloc(sizeof(char) * line->length + length); if (position > 0) position--; if (position > line->length) @@ -183,7 +183,7 @@ elm_code_line_text_remove(Elm_Code_Line *line, unsigned int position, int length if (!line) return; - removed = malloc(sizeof(char) * line->length - length + 1); + removed = malloc(sizeof(char) * line->length - length); if (position > 0) position--; if (position > line->length) 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 3838c10..cd837cf 100644 --- a/elm_code/src/lib/widget/elm_code_widget_selection.c +++ b/elm_code/src/lib/widget/elm_code_widget_selection.c @@ -117,8 +117,9 @@ _elm_code_widget_selection_delete_single(Elm_Code_Widget_Data *pd) line = elm_code_file_line_get(pd->code->file, pd->selection->start_line); old = elm_code_line_text_get(line, &old_length); - length = line->length - (pd->selection->end_col - pd->selection->start_col); - content = malloc(sizeof(char) * (length + 1)); + length = line->length - (pd->selection->end_col - pd->selection->start_col + 1); + content = malloc(sizeof(char) * length); + snprintf(content, pd->selection->start_col, old); snprintf(content + pd->selection->start_col - 1, old_length - pd->selection->end_col + 1, old + pd->selection->end_col); --