X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fhttp.c;h=27234198779b7a0b1a44adb99182841bb7c493f6;hp=c3adbf40755150d2ab158f674941302b8dd521cb;hb=8477863e75991703a4c2da9f720bcdef3ea16521;hpb=5b42f5681f65f24ac4473aae9470d78d65588a25 diff --git a/src/http.c b/src/http.c index c3adbf40..27234198 100644 --- a/src/http.c +++ b/src/http.c @@ -2935,6 +2935,7 @@ http_atotm (const char *time_string) Netscape cookie specification.) */ }; const char *oldlocale; + char savedlocale[256]; size_t i; time_t ret = (time_t) -1; @@ -2942,6 +2943,16 @@ http_atotm (const char *time_string) non-English locales, which we work around by temporarily setting locale to C before invoking strptime. */ oldlocale = setlocale (LC_TIME, NULL); + if (oldlocale) + { + size_t l = strlen (oldlocale); + if (l >= sizeof savedlocale) + savedlocale[0] = '\0'; + else + memcpy (savedlocale, oldlocale, l); + } + else savedlocale[0] = '\0'; + setlocale (LC_TIME, "C"); for (i = 0; i < countof (time_formats); i++) @@ -2961,7 +2972,8 @@ http_atotm (const char *time_string) } /* Restore the previous locale. */ - setlocale (LC_TIME, oldlocale); + if (savedlocale[0]) + setlocale (LC_TIME, savedlocale); return ret; }