elm code - handle alloc failure for line split

this culd optentially use large offsets before accessing the ptr thus
it may not segv inthe first page but actually work if positionoffsets
are large enouh, so handle this case explicitly.

@fix

found by PVS studio
This commit is contained in:
Carsten Haitzler 2017-07-31 12:00:45 +09:00
parent 6e82f90807
commit d639063b50
1 changed files with 4 additions and 2 deletions

View File

@ -68,8 +68,10 @@ EAPI void elm_code_line_split_at(Elm_Code_Line *line, unsigned int position)
char *content;
unsigned int length;
content = (char *) elm_code_line_text_get(line, &length);
content = strndup(content, length);
content = (char *) elm_code_line_text_get(line, &length);
if (!content) return;
content = strndup(content, length);
if (!content) return;
elm_code_file_line_insert(line->file, line->number + 1, "", 0, NULL);
newline = elm_code_file_line_get(line->file, line->number + 1);