From: Collin Funk Date: Fri, 10 Oct 2025 03:42:05 +0000 (-0700) Subject: getline tests: Add a test for the glibc bug. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55e6cae9e8f0e133914d1e4ae25db07d913e6760;p=thirdparty%2Fgnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index f3c4a487d8..07f0503f84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2025-10-10 Collin Funk + 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 diff --git a/tests/test-getline.c b/tests/test-getline.c index 66c44d5dc9..bc559c6dc5 100644 --- a/tests/test-getline.c +++ b/tests/test-getline.c @@ -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);