public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] Avoid crash when calling __localeconv_l with __C_locale
Date: Wed, 24 Aug 2016 17:47:00 -0000	[thread overview]
Message-ID: <20160824174703.51248.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a703d64ad7edac344e4959e8d624ce1d8012678b

commit a703d64ad7edac344e4959e8d624ce1d8012678b
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Wed Aug 24 19:46:55 2016 +0200

    Avoid crash when calling __localeconv_l with __C_locale
    
    __C_locale is const.  Thus, overwriting the lconv values in __localeconv_l
    will try to write to a R/O region.  Given the lconv values in __C_locale
    are initialized, there's no reason to write them in __localeconv_l at all.
    Just return &__C_locale.lconv.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 newlib/libc/locale/localeconv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/newlib/libc/locale/localeconv.c b/newlib/libc/locale/localeconv.c
index 1f8816d..165f6f7 100644
--- a/newlib/libc/locale/localeconv.c
+++ b/newlib/libc/locale/localeconv.c
@@ -6,6 +6,9 @@ struct lconv *
 __localeconv_l (struct __locale_t *locale)
 {
   struct lconv *lconv = &locale->lconv;
+  if (locale == __get_C_locale ())
+    return lconv;
+
 #ifdef __HAVE_LOCALE_INFO__
   const struct lc_numeric_T *n = __get_numeric_locale (locale);
   const struct lc_monetary_T *m = __get_monetary_locale (locale);


                 reply	other threads:[~2016-08-24 17:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20160824174703.51248.qmail@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=newlib-cvs@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).