]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
getline tests: Add a test for the glibc bug.
authorCollin Funk <collin.funk1@gmail.com>
Fri, 10 Oct 2025 03:42:05 +0000 (20:42 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Sat, 11 Oct 2025 00:38:07 +0000 (17:38 -0700)
* tests/test-getline.c (main): Check that the buffer is terminated with
a NUL character when the first character read is EOF.

ChangeLog
tests/test-getline.c

index f3c4a487d88176b0fad9955e46a7e283f26fc4ee..07f0503f84fbb648dfa3425f1a1595181ff86616 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2025-10-10  Collin Funk  <collin.funk1@gmail.com>
 
+       getline tests: Add a test for the glibc bug.
+       * tests/test-getline.c (main): Check that the buffer is terminated with
+       a NUL character when the first character read is EOF.
+
        getline: Work around a glibc bug.
        * m4/getline.m4 (gl_FUNC_GETLINE): Check that the buffer is terminated
        with a NUL character when the first character read is EOF. Guess that
index 66c44d5dc9d7d7edf836b60bfb395f6890b5a8d2..bc559c6dc54c4758f05f2703f2a7c4f10ff746eb 100644 (file)
@@ -84,7 +84,11 @@ main (void)
   ASSERT (memcmp (line, "d\0f", 4) == 0);
   ASSERT (3 < len);
 
+  /* Test that reading an EOF will terminate the buffer with a NUL
+     character.  */
   result = getline (&line, &len, f);
+  ASSERT (0 < len);
+  ASSERT (line[0] == '\0');
   ASSERT (result == -1);
 
   free (line);