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