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