From 776275a747658f8ea5c1a4e0b514b0920de3f68e Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Wed, 20 May 2020 14:56:13 +0300 Subject: [PATCH] LibC: Handle fgets(size = 0) I accidentally broke this in the recent rewrite. This reinstantiates the behavior implemented in https://github.com/SerenityOS/serenity/commit/65714685259d1ea4ba9d32bc41aee6fc8c56a645. --- Libraries/LibC/stdio.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Libraries/LibC/stdio.cpp b/Libraries/LibC/stdio.cpp index f000811b196..4075ed3321e 100644 --- a/Libraries/LibC/stdio.cpp +++ b/Libraries/LibC/stdio.cpp @@ -324,6 +324,9 @@ bool FILE::gets(u8* data, size_t size) // separate implementation. size_t total_read = 0; + if (size == 0) + return false; + while (size > 1) { if (m_buffer.may_use()) { // Let's see if the buffer has something queued for us.