summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-07-31 12:00:45 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-07-31 12:00:45 +0900
commitd639063b507b3339095edb3c0b685c03b1b293fd (patch)
tree39c069670527898fdaf900b94d9f609d06381b65
parent6e82f90807e19993a77a007e4ce0a9dbcd082d9b (diff)
downloadefl-d639063b507b3339095edb3c0b685c03b1b293fd.tar.gz
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
-rw-r--r--src/lib/elementary/elm_code_line.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/elementary/elm_code_line.c b/src/lib/elementary/elm_code_line.c
index e27cb5d74d..3d5cc2f7be 100644
--- a/src/lib/elementary/elm_code_line.c
+++ b/src/lib/elementary/elm_code_line.c
@@ -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);