mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +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
Notes:
sideshowbarker
2024-07-19 06:44:24 +09:00
Author: https://github.com/Jongy Commit: https://github.com/SerenityOS/serenity/commit/65714685259 Pull-request: https://github.com/SerenityOS/serenity/pull/2184
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)
|
||||
{
|
||||
ASSERT(stream);
|
||||
ASSERT(size);
|
||||
if (size == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ssize_t nread = 0;
|
||||
while (nread < (size - 1)) {
|
||||
int ch = fgetc(stream);
|
||||
|
|
Loading…
Reference in a new issue