Fixed endless loop.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15576 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4c0af4a82e
commit
8f75497433
@ -51,25 +51,28 @@ ConsoleHandle::WriteAt(void */*cookie*/, off_t /*pos*/, const void *buffer, size
|
|||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
|
|
||||||
for (; length < bufferSize; length++) {
|
for (; length < bufferSize; length++) {
|
||||||
if (string[length] == '\r')
|
if (string[length] == '\r' && length + 1 < bufferSize) {
|
||||||
length += 2;
|
length += 2;
|
||||||
else if (string[length] == '\n')
|
} else if (string[length] == '\n') {
|
||||||
|
newLine = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > bufferSize)
|
if (length > bufferSize)
|
||||||
length = bufferSize;
|
length = bufferSize;
|
||||||
|
|
||||||
of_write(fHandle, string, length);
|
if (length > 0) {
|
||||||
|
of_write(fHandle, string, length);
|
||||||
|
string += length;
|
||||||
|
bufferSize -= length;
|
||||||
|
}
|
||||||
|
|
||||||
if (newLine) {
|
if (newLine) {
|
||||||
of_write(fHandle, "\r\n", 2);
|
of_write(fHandle, "\r\n", 2);
|
||||||
string++;
|
string++;
|
||||||
bufferSize--;
|
bufferSize--;
|
||||||
}
|
}
|
||||||
|
|
||||||
string += length;
|
|
||||||
bufferSize -= length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return string - (char *)buffer;
|
return string - (char *)buffer;
|
||||||
|
Loading…
Reference in New Issue
Block a user