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)
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)
68 char *content; 68 char *content;
69 unsigned int length; 69 unsigned int length;
70 70
71 content = (char *) elm_code_line_text_get(line, &length); 71 content = (char *) elm_code_line_text_get(line, &length);
72 content = strndup(content, length); 72 if (!content) return;
73 content = strndup(content, length);
74 if (!content) return;
73 elm_code_file_line_insert(line->file, line->number + 1, "", 0, NULL); 75 elm_code_file_line_insert(line->file, line->number + 1, "", 0, NULL);
74 newline = elm_code_file_line_get(line->file, line->number + 1); 76 newline = elm_code_file_line_get(line->file, line->number + 1);
75 77