50f89d
commit 07da99aad93c9364acb7efdab47c27ba698f6313
50f89d
Author: Florian Weimer <fweimer@redhat.com>
50f89d
Date:   Tue Oct 30 13:55:01 2018 +0100
50f89d
50f89d
    stdlib/tst-strtod-overflow: Switch to support_blob_repeat
50f89d
    
50f89d
    This is another test with an avoidable large memory allocation.
50f89d
50f89d
diff --git a/stdlib/tst-strtod-overflow.c b/stdlib/tst-strtod-overflow.c
50f89d
index d14638d68ef4f471..dc53c1e521443e1d 100644
50f89d
--- a/stdlib/tst-strtod-overflow.c
50f89d
+++ b/stdlib/tst-strtod-overflow.c
50f89d
@@ -19,6 +19,8 @@
50f89d
 #include <stdio.h>
50f89d
 #include <stdlib.h>
50f89d
 #include <string.h>
50f89d
+#include <support/blob_repeat.h>
50f89d
+#include <support/test-driver.h>
50f89d
 
50f89d
 #define EXPONENT "e-2147483649"
50f89d
 #define SIZE 214748364
50f89d
@@ -26,21 +28,23 @@
50f89d
 static int
50f89d
 do_test (void)
50f89d
 {
50f89d
-  char *p = malloc (1 + SIZE + sizeof (EXPONENT));
50f89d
-  if (p == NULL)
50f89d
+  struct support_blob_repeat repeat = support_blob_repeat_allocate
50f89d
+    ("0", 1, 1 + SIZE + sizeof (EXPONENT));
50f89d
+  if (repeat.size == 0)
50f89d
     {
50f89d
-      puts ("malloc failed, cannot test for overflow");
50f89d
-      return 0;
50f89d
+      puts ("warning: memory allocation failed, cannot test for overflow");
50f89d
+      return EXIT_UNSUPPORTED;
50f89d
     }
50f89d
+  char *p = repeat.start;
50f89d
   p[0] = '1';
50f89d
-  memset (p + 1, '0', SIZE);
50f89d
   memcpy (p + 1 + SIZE, EXPONENT, sizeof (EXPONENT));
50f89d
   double d = strtod (p, NULL);
50f89d
   if (d != 0)
50f89d
     {
50f89d
-      printf ("strtod returned wrong value: %a\n", d);
50f89d
+      printf ("error: strtod returned wrong value: %a\n", d);
50f89d
       return 1;
50f89d
     }
50f89d
+  support_blob_repeat_free (&repeat);
50f89d
   return 0;
50f89d
 }
50f89d