eina file: Fix rare crash in line iteration
authorJean-Philippe Andre <jp.andre@samsung.com>
Mon, 3 Jul 2017 07:22:01 +0000 (16:22 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Mon, 3 Jul 2017 07:23:40 +0000 (16:23 +0900)
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.

src/lib/eina/eina_file_common.c

index 4b94d1d..8d7472b 100644 (file)
@@ -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;