diff options
author | Tony Cook <tony@develop-help.com> | 2019-09-16 16:38:26 +1000 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2019-10-24 12:10:34 -0700 |
commit | bcb1da5c29c3a2534a0e43874974b83c9c8b174c (patch) | |
tree | e23fad9b95f04a7d830fd068556267b55a21f862 /vutil.c | |
parent | 8b64b5d1624be026f0eebe3bf2ddbd0c086a4d49 (diff) | |
download | perl-bcb1da5c29c3a2534a0e43874974b83c9c8b174c.tar.gz |
ensure locale_name_on_entry isn't clobbered
If the return value of setlocale() is static storage, the call to
setlocale(LC_NUMERIC, "C"); could overwrite it.
If the return value of setlocale() is malloced, the call to
setlocale(LC_NUMERIC, "C"); could free it.
Either way, we need to copy it. Fixes gh #17054 rt134212
Diffstat (limited to 'vutil.c')
-rw-r--r-- | vutil.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -643,6 +643,8 @@ VER_NV: if ( strNE(locale_name_on_entry, "C") && strNE(locale_name_on_entry, "POSIX")) { + /* the setlocale() call might free or overwrite the name */ + locale_name_on_entry = savepv(locale_name_on_entry); setlocale(LC_NUMERIC, "C"); } else { /* This value indicates to the restore code that we didn't @@ -666,6 +668,8 @@ VER_NV: if ( strNE(locale_name_on_entry, "C") && strNE(locale_name_on_entry, "POSIX")) { + /* the setlocale() call might free or overwrite the name */ + locale_name_on_entry = savepv(locale_name_on_entry); setlocale(LC_NUMERIC, "C"); } else { /* This value indicates to the restore code that we @@ -715,6 +719,7 @@ VER_NV: if (locale_name_on_entry) { setlocale(LC_NUMERIC, locale_name_on_entry); + Safefree(locale_name_on_entry); } LC_NUMERIC_UNLOCK; /* End critical section */ @@ -723,6 +728,7 @@ VER_NV: if (locale_name_on_entry) { setlocale(LC_NUMERIC, locale_name_on_entry); + Safefree(locale_name_on_entry); LC_NUMERIC_UNLOCK; } else if (locale_obj_on_entry == PL_underlying_numeric_obj) { |