Sfoglia il codice sorgente

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

"Play C games, win C prizes."
Andreas Kling 5 anni fa
parent
commit
edac8704de
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  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(size);
     ssize_t nread = 0;
-    while (nread < (size + 1)) {
+    while (nread < (size - 1)) {
         int ch = fgetc(stream);
         if (ch == EOF)
             break;