mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +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:
parent
ebe47de0b2
commit
6571468525
1 changed files with 4 additions and 1 deletions
|
@ -137,7 +137,10 @@ int fflush(FILE* stream)
|
||||||
char* fgets(char* buffer, int size, FILE* stream)
|
char* fgets(char* buffer, int size, FILE* stream)
|
||||||
{
|
{
|
||||||
ASSERT(stream);
|
ASSERT(stream);
|
||||||
ASSERT(size);
|
if (size == 0) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t nread = 0;
|
ssize_t nread = 0;
|
||||||
while (nread < (size - 1)) {
|
while (nread < (size - 1)) {
|
||||||
int ch = fgetc(stream);
|
int ch = fgetc(stream);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue