]> sourceware.org Git - glibc.git/commitdiff
tst-fmon/tst-numeric: switch malloc to static stack space [BZ #19671]
authorMike Frysinger <vapier@gentoo.org>
Fri, 22 Apr 2016 21:11:09 +0000 (17:11 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sat, 23 Apr 2016 20:14:01 +0000 (16:14 -0400)
The current test code doesn't check the return value of malloc.
This should rarely (if ever) cause a problem, but rather than add
some return value checks, just statically allocate the buffer on
the stack.  This will never fail (or if it does, we've got much
bigger problems that don't matter to the test).

localedata/ChangeLog
localedata/tst-fmon.c
localedata/tst-numeric.c

index 13d1e4709c995c92af354b1409c67746ad95a2cd..9815a9e81ef529fb79f34349d5f49cc14c09f681 100644 (file)
@@ -1,3 +1,10 @@
+2016-04-23  Mike Frysinger  <vapier@gentoo.org>
+
+       [BZ #19671]
+       * tst-fmon.c (main): Change s from malloc to s[200].  Change 2nd
+       arg to strfmon from 200 to sizeof (s).
+       * tst-numeric.c (main): Likewise.
+
 2016-04-23  Mike Frysinger  <vapier@gentoo.org>
 
        * tst-langinfo.sh: Update YESEXPR & NOEXPR baselines to match
index 995cf9056c5db592565a70b4a2cea16c5ace61c4..62cd7dbfd55309cf1b5c87ad599464f321b6e394 100644 (file)
@@ -40,7 +40,7 @@
 int
 main (int argc, char *argv[])
 {
-  char *s = malloc (201);
+  char s[200];
 
   if (setlocale (LC_MONETARY, argv[1]) == NULL)
     {
@@ -48,7 +48,7 @@ main (int argc, char *argv[])
       exit (EXIT_SETLOCALE);
     }
 
-  if (strfmon (s, 200, argv[2], (double) atof (argv[3])) == -1)
+  if (strfmon (s, sizeof (s), argv[2], (double) atof (argv[3])) == -1)
     {
       perror ("strfmon");
       exit (EXIT_STRFMON);
index 46a6b481502509d82cb53f80802e04780ba03290..64abb0a9680696de75d28cfb320f93595a1c14e9 100644 (file)
@@ -41,7 +41,7 @@
 int
 main (int argc, char *argv[])
 {
-  char *s = malloc (201);
+  char s[200];
   double val;
 
   /* Make sure to read the value before setting of the locale, as
@@ -54,7 +54,7 @@ main (int argc, char *argv[])
       exit (EXIT_SETLOCALE);
     }
 
-  if (snprintf (s, 200, argv[2], val) == -1)
+  if (snprintf (s, sizeof (s), argv[2], val) == -1)
     {
       perror ("snprintf");
       exit (EXIT_SNPRINTF);
This page took 0.05684 seconds and 5 git commands to generate.