LibC: fgets() should return null on 0-length EOF reads.

This commit is contained in:
Andreas Kling 2019-02-26 22:32:51 +01:00
parent a356746d04
commit 83e78648e4

View file

@ -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;