1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +00:00

LibC: Return nullptr in fgets for size=0

I had this assert trigger, I believe in a legitimate case.
This is the behavior glic and musl follow.
This commit is contained in:
Yonatan Goldschmidt 2020-05-10 23:34:02 +03:00 committed by Andreas Kling
parent ebe47de0b2
commit 6571468525

View file

@ -137,7 +137,10 @@ int fflush(FILE* stream)
char* fgets(char* buffer, int size, FILE* stream)
{
ASSERT(stream);
ASSERT(size);
if (size == 0) {
return nullptr;
}
ssize_t nread = 0;
while (nread < (size - 1)) {
int ch = fgetc(stream);