From: Jean-Philippe Andre Date: Mon, 3 Jul 2017 07:22:01 +0000 (+0900) Subject: eina file: Fix rare crash in line iteration X-Git-Tag: upstream/1.20.0~378 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=daf87093f85972fc595560a3ac8537b6c74e01b0;p=platform%2Fupstream%2Fefl.git eina file: Fix rare crash in line iteration I'm not sure about the rest of this code, so it's possible that the index is increased even if it shouldn't. But I've observed a crash at this line, apparently when reaching the end pointer. --- diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c index 4b94d1d..8d7472b 100644 --- a/src/lib/eina/eina_file_common.c +++ b/src/lib/eina/eina_file_common.c @@ -606,8 +606,8 @@ _eina_file_map_lines_iterator_next(Eina_Lines_Iterator *it, void **data) match = *it->current.end; if (it->current.index > 0) it->current.end++; - while ((*it->current.end == '\n' || *it->current.end == '\r') - && it->current.end < it->end) + while (it->current.end < it->end && + (*it->current.end == '\n' || *it->current.end == '\r')) { if (match == *it->current.end) break;