diff --git a/stdlib/test-bz22786.c b/stdlib/test-bz22786.c index d1aa691..777bf91 100644 --- a/stdlib/test-bz22786.c +++ b/stdlib/test-bz22786.c @@ -39,16 +39,25 @@ do_test (void) const char *lnk = xasprintf ("%s/symlink", dir); const size_t path_len = (size_t) INT_MAX + strlen (lnk) + 1; - TEST_VERIFY_EXIT (symlink (".", lnk) == 0); - DIAG_PUSH_NEEDS_COMMENT; #if __GNUC_PREREQ (7, 0) /* GCC 7 warns about too-large allocations; here we need such allocation to succeed for the test to work. */ DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than="); #endif - char *path = xmalloc (path_len); + char *path = malloc (path_len); DIAG_POP_NEEDS_COMMENT; + if (path == NULL) + { + printf ("malloc (%zu): %m\n", path_len); + /* On 31-bit s390 the malloc will always fail as we do not have + so much memory, and we want to mark the test unsupported. + Likewise on systems with little physical memory the test will + fail and should be unsupported. */ + return EXIT_UNSUPPORTED; + } + + TEST_VERIFY_EXIT (symlink (".", lnk) == 0); /* Construct very long path = "/tmp/bz22786.XXXX/symlink/aaaa....." */ char *p = mempcpy (path, lnk, strlen (lnk));