elm_code: Fix crashes with backspace on OpenBSD

@fix
This commit is contained in:
Andy Williams 2017-04-05 23:59:23 +01:00
parent 650606ab90
commit ddb189bb1f
2 changed files with 6 additions and 4 deletions

View File

@ -96,8 +96,10 @@ _elm_code_line_merge_into(Elm_Code_Line *line1, Elm_Code_Line *line2)
text2 = elm_code_line_text_get(line2, &length2);
newtext = malloc(sizeof(char) * (length1 + length2 + 1));
snprintf(newtext, length1 + 1, "%s", text1);
snprintf(newtext + length1, length2 + 1, "%s", text2);
if (length1 > 0)
snprintf(newtext, length1 + 1, "%s", text1);
if (length2 > 0)
snprintf(newtext + length1, length2 + 1, "%s", text2);
tokens1 = line1->tokens;
line1->tokens = NULL;

View File

@ -74,8 +74,8 @@ _elm_code_widget_text_multi_get(Elm_Code_Widget *widget, Elm_Code_Widget_Data *p
for (row = start_line + 1; row < end_line; row++)
{
line = elm_code_file_line_get(pd->code->file, row);
snprintf(ptr, line->length + 1, "%s",
elm_code_line_text_get(line, NULL));
if (line->length > 0)
snprintf(ptr, line->length + 1, "%s", elm_code_line_text_get(line, NULL));
snprintf(ptr + line->length, newline_len + 1, "%s", newline);
ptr += line->length + newline_len;