Eric Blake <[email protected]> writes: > According to Simon Josefsson on 5/26/2009 6:15 AM: >> +2009-05-26 Simon Josefsson <[email protected]> >> + >> + * tests/test-strstr.c: Add another self-test. >> { >> + /* See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737 */ >> + char *input = strdup ("aBaaaaaaaaaaax"); > > Did you take the proper precautions to ensure strdup is available? I'd > almost feel better if you rewrote this to use malloc/strcpy, rather than > dragging in dependencies just for the test.
Good point. Pushed. /Simon >From 5b63b76064a130bdaadb1fda7ab50e82896446e1 Mon Sep 17 00:00:00 2001 From: Simon Josefsson <[email protected]> Date: Tue, 26 May 2009 15:31:53 +0200 Subject: [PATCH] tests/test-strstr.c: Rewrite to use malloc/strcpy instead of strdup. Suggested by Eric Blake <[email protected]>. --- ChangeLog | 2 ++ tests/test-strstr.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96d5f10..5b5348c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2009-05-26 Simon Josefsson <[email protected]> * tests/test-strstr.c: Add another self-test. + * tests/test-strstr.c: Rewrite to use malloc/strcpy instead of + strdup. Suggested by Eric Blake <[email protected]>. 2009-05-23 Bruno Haible <[email protected]> diff --git a/tests/test-strstr.c b/tests/test-strstr.c index d8bec15..600f7c7 100644 --- a/tests/test-strstr.c +++ b/tests/test-strstr.c @@ -62,8 +62,12 @@ main (int argc, char *argv[]) { /* See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737 */ - char *input = strdup ("aBaaaaaaaaaaax"); - const char *result = strstr (input, "B1x"); + const char *fix = "aBaaaaaaaaaaax"; + char *input = malloc (strlen (fix) + 1); + const char *result; + + strcpy (input, fix); + result = strstr (input, "B1x"); ASSERT (result == NULL); free (input); } -- 1.6.2.4
