* tests/test-getdelim.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>
+ 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
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);