From 8f754974334ba0d1b36a26b78c79a9501550cf17 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 18 Dec 2005 14:35:31 +0000 Subject: [PATCH] Fixed endless loop. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15576 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/boot/platform/openfirmware/console.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/system/boot/platform/openfirmware/console.cpp b/src/system/boot/platform/openfirmware/console.cpp index b28fb28b59..1821178891 100644 --- a/src/system/boot/platform/openfirmware/console.cpp +++ b/src/system/boot/platform/openfirmware/console.cpp @@ -51,25 +51,28 @@ ConsoleHandle::WriteAt(void */*cookie*/, off_t /*pos*/, const void *buffer, size size_t length = 0; for (; length < bufferSize; length++) { - if (string[length] == '\r') + if (string[length] == '\r' && length + 1 < bufferSize) { length += 2; - else if (string[length] == '\n') + } else if (string[length] == '\n') { + newLine = true; break; + } } if (length > bufferSize) length = bufferSize; - of_write(fHandle, string, length); + if (length > 0) { + of_write(fHandle, string, length); + string += length; + bufferSize -= length; + } if (newLine) { of_write(fHandle, "\r\n", 2); string++; bufferSize--; } - - string += length; - bufferSize -= length; } return string - (char *)buffer;