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