mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
LibC: fgets() should return null on 0-length EOF reads.
This commit is contained in:
parent
a356746d04
commit
83e78648e4
1 changed files with 4 additions and 1 deletions
|
@ -104,8 +104,11 @@ char* fgets(char* buffer, int size, FILE* stream)
|
|||
if (nread >= size)
|
||||
break;
|
||||
int ch = fgetc(stream);
|
||||
if (ch == EOF)
|
||||
if (ch == EOF) {
|
||||
if (nread == 0)
|
||||
return nullptr;
|
||||
break;
|
||||
}
|
||||
buffer[nread++] = ch;
|
||||
if (!ch || ch == '\n')
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue