From: Alastair Poole Date: Thu, 16 Aug 2018 14:12:35 +0000 (-0400) Subject: elm_code_line: fix potential crash. X-Git-Tag: submit/sandbox/upgrade/efl120/20180919.042345~188 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de4e78c4e5f5abf08e412a7ac6e93042fa2b1a96;p=platform%2Fupstream%2Fefl.git elm_code_line: fix potential crash. Summary: This can occur and thus malloc will return NULL when line->length is 0. Check for !line->length and return. Very difficult to reproduce, but I had managed three times, and avoided a crash. Reviewers: #committers, ajwillia.ms, zmike Reviewed By: #committers, zmike Subscribers: cedric, #reviewers, zmike Tags: #efl Differential Revision: https://phab.enlightenment.org/D6842 --- diff --git a/src/lib/elementary/elm_code_text.c b/src/lib/elementary/elm_code_text.c index 1ebdb09..641dc41 100644 --- a/src/lib/elementary/elm_code_text.c +++ b/src/lib/elementary/elm_code_text.c @@ -189,7 +189,7 @@ elm_code_line_text_remove(Elm_Code_Line *line, unsigned int position, int length Elm_Code_File *file; char *removed; - if (!line) + if (!line || !line->length) return; removed = malloc(sizeof(char) * line->length - length);