diff options
Diffstat (limited to 'libio/test-fmemopen.c')
-rw-r--r-- | libio/test-fmemopen.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/libio/test-fmemopen.c b/libio/test-fmemopen.c index 63ca89f300..e8e757f351 100644 --- a/libio/test-fmemopen.c +++ b/libio/test-fmemopen.c @@ -22,6 +22,32 @@ static char buffer[] = "foobar"; #include <stdio.h> #include <string.h> #include <errno.h> +#include <mcheck.h> + +static int +do_bz18820 (void) +{ + char ch; + FILE *stream; + + stream = fmemopen (&ch, 1, "?"); + if (stream) + { + printf ("fmemopen: expected NULL, got %p\n", stream); + fclose (stream); + return 1; + } + + stream = fmemopen (NULL, 42, "?"); + if (stream) + { + printf ("fmemopen: expected NULL, got %p\n", stream); + fclose (stream); + return 2; + } + + return 0; +} static int do_test (void) @@ -30,6 +56,8 @@ do_test (void) FILE *stream; int ret = 0; + mtrace (); + stream = fmemopen (buffer, strlen (buffer), "r+"); while ((ch = fgetc (stream)) != EOF) @@ -44,7 +72,7 @@ do_test (void) fclose (stream); - return ret; + return ret + do_bz18820 (); } #define TEST_FUNCTION do_test () |