* tests/test-getline.c (main): Check that the buffer is terminated with
a NUL character when the first character read is EOF.
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
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);