bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] avoid failed assertion in test-getndelim2.c


From: Jim Meyering
Subject: [PATCH] avoid failed assertion in test-getndelim2.c
Date: Sat, 03 May 2008 12:59:01 +0200

Since 'f' is the next-to-last byte of the file (the delimiter
is the last one), the minimum buffer size that accommodates the
'f'-terminated "line" plus terminating NUL has length 501*14.

That's what happens on Solaris 10 and caused the test failure.
So I've just pushed this:

       avoid failed assertion with tight malloc
       * tests/test-getndelim2.c: Correct an off-by-one assertion.

diff --git a/ChangeLog b/ChangeLog
index f566efa..ec7d295 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-05-03  Jim Meyering  <address@hidden>
+
+       avoid failed assertion with tight malloc
+       * tests/test-getndelim2.c: Correct an off-by-one assertion.
+
 2008-05-03  Simon Josefsson  <address@hidden>

        * m4/inet_pton.m4: Set HAVE_DECL_INET_PTON to 0 when declarations
diff --git a/tests/test-getndelim2.c b/tests/test-getndelim2.c
index 10ec1d8..d1eb12a 100644
--- a/tests/test-getndelim2.c
+++ b/tests/test-getndelim2.c
@@ -138,7 +138,7 @@ main (int argc, char **argv)

     result = getndelim2 (&line, &len, 0, GETNLINE_NO_LIMIT, 'g', 'f', f);
     ASSERT (result == 501 * 14 - 1);
-    ASSERT (501 * 14 < len);
+    ASSERT (501 * 14 <= len);
     buffer[499] = 'f';
     buffer[500] = '\0';
     ASSERT (strcmp (buffer, line + 501 * 13) == 0);
--
1.5.5.1.117.ga349




reply via email to

[Prev in Thread] Current Thread [Next in Thread]