From 12ea4944775e5f1bc6360773dfe817838060add3 Mon Sep 17 00:00:00 2001 From: Roman Iten Date: Mon, 13 Apr 2020 17:07:38 +0200 Subject: [PATCH] vfs/File_content: fix end condition in for_each_line Fixes #3729 --- repos/os/include/os/vfs.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/repos/os/include/os/vfs.h b/repos/os/include/os/vfs.h index 501a94f09..f754e40c2 100644 --- a/repos/os/include/os/vfs.h +++ b/repos/os/include/os/vfs.h @@ -526,17 +526,14 @@ class Genode::File_content template void for_each_line(FN const &fn) const { - if (_buffer.size == 0) - return; - char const *src = _buffer.ptr; char const *curr_line = src; size_t curr_line_len = 0; for (size_t n = 0; ; n++) { - char const c = *src++; - bool const end_of_data = (c == 0 || n == _buffer.size); + char const c = (n == _buffer.size) ? 0 : *src++; + bool const end_of_data = (c == 0); bool const end_of_line = (c == '\n'); if (!end_of_data && !end_of_line) {