Jelajahi Sumber

LibC: Fix dumb off-by-two in fgets() :^)

"Play C games, win C prizes."
Andreas Kling 5 tahun lalu
induk
melakukan
edac8704de
1 mengubah file dengan 1 tambahan dan 1 penghapusan
  1. 1 1
      Libraries/LibC/stdio.cpp

+ 1 - 1
Libraries/LibC/stdio.cpp

@@ -108,7 +108,7 @@ char* fgets(char* buffer, int size, FILE* stream)
     ASSERT(stream);
     ASSERT(stream);
     ASSERT(size);
     ASSERT(size);
     ssize_t nread = 0;
     ssize_t nread = 0;
-    while (nread < (size + 1)) {
+    while (nread < (size - 1)) {
         int ch = fgetc(stream);
         int ch = fgetc(stream);
         if (ch == EOF)
         if (ch == EOF)
             break;
             break;