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

ChangeLog
tests/test-getdelim.c

index bb326cdfdf77510a0863c283e6718edf0c783c40..7e14807d1272a584043b50e5554b3b68b09d29ea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2025-10-10  Collin Funk  <collin.funk1@gmail.com>
 
+       getdelim tests: Add a test for the glibc bug.
+       * tests/test-getdelim.c (main): Check that the buffer is terminated with
+       a NUL character when the first character read is EOF.
+
        getdelim: Work around a glibc bug.
        * m4/getdelim.m4 (gl_FUNC_GETDELIM): Check that the buffer is terminated
        with a NUL character when the first character read is EOF. Guess that
index b7911464e3d15ef1afd75c62ceee637e5e8401cf..3696d0f5ab5a778b146a2e2323b853666d7ccd69 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 = getdelim (&line, &len, 'n', f);
+  ASSERT (0 < len);
+  ASSERT (line[0] == '\0');
   ASSERT (result == -1);
 
   free (line);