Complete the ending newline crash fix

This commit is contained in:
Andy Williams 2016-02-21 18:48:07 +00:00
parent 4a4dc31f9f
commit 5dc607ecea
1 changed files with 16 additions and 4 deletions

View File

@ -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);