public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: libc-alpha@sourceware.org
Subject: [PATCH] tst-fmon/tst-numeric: switch malloc to static stack space [BZ #19671]
Date: Fri, 22 Apr 2016 21:12:00 -0000	[thread overview]
Message-ID: <1461359558-26367-1-git-send-email-vapier@gentoo.org> (raw)

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).

Checked that the tests still pass on x86_64-linux-gnu.
---
 localedata/tst-fmon.c    | 2 +-
 localedata/tst-numeric.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/localedata/tst-fmon.c b/localedata/tst-fmon.c
index 995cf90..1359775 100644
--- a/localedata/tst-fmon.c
+++ b/localedata/tst-fmon.c
@@ -40,7 +40,7 @@
 int
 main (int argc, char *argv[])
 {
-  char *s = malloc (201);
+  char s[201];
 
   if (setlocale (LC_MONETARY, argv[1]) == NULL)
     {
diff --git a/localedata/tst-numeric.c b/localedata/tst-numeric.c
index 46a6b48..ac06965 100644
--- a/localedata/tst-numeric.c
+++ b/localedata/tst-numeric.c
@@ -41,7 +41,7 @@
 int
 main (int argc, char *argv[])
 {
-  char *s = malloc (201);
+  char s[201];
   double val;
 
   /* Make sure to read the value before setting of the locale, as
-- 
2.7.4

             reply	other threads:[~2016-04-22 21:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-22 21:12 Mike Frysinger [this message]
2016-04-23 12:24 ` Florian Weimer
2016-04-23 18:25   ` Mike Frysinger
2016-04-23 20:05     ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461359558-26367-1-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).