Stream#ReadLine(): fix false positive buffer underflow indicator

refs #6354
This commit is contained in:
Alexander A. Klimov 2018-06-20 09:59:18 +02:00
parent eb1f37905d
commit 02d1f1cc57
1 changed files with 10 additions and 1 deletions

View File

@ -143,7 +143,16 @@ StreamReadStatus Stream::ReadLine(String *line, StreamReadContext& context, bool
} }
} }
context.MustRead = (count <= 1); switch (count) {
case 0:
context.MustRead = true;
break;
case 1:
context.MustRead = first_newline == (context.Size - 1u);
break;
default:
context.MustRead = false;
}
if (count > 0) { if (count > 0) {
*line = String(context.Buffer, &(context.Buffer[first_newline])); *line = String(context.Buffer, &(context.Buffer[first_newline]));