From 283e53054aa39d7e59043e2e92d346334f6223dc Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Tue, 13 Feb 2007 02:06:04 +0000 Subject: [PATCH] fix minor problem in locale switching --- src/share/grabbag/replaygain.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/share/grabbag/replaygain.c b/src/share/grabbag/replaygain.c index 8fedce7d..b3d3d210 100644 --- a/src/share/grabbag/replaygain.c +++ b/src/share/grabbag/replaygain.c @@ -98,7 +98,9 @@ static FLAC__bool append_tag_(FLAC__StreamMetadata *block, const char *format, c * We need to save the old locale and switch to "C" because the locale * influences the formatting of %f and we want it a certain way. */ - saved_locale = setlocale(LC_ALL, 0); + saved_locale = strdup(setlocale(LC_ALL, 0)); + if (0 == saved_locale) + return false; setlocale(LC_ALL, "C"); #if defined _MSC_VER || defined __MINGW32__ _snprintf(buffer, sizeof(buffer)-1, format, name, value); @@ -106,6 +108,7 @@ static FLAC__bool append_tag_(FLAC__StreamMetadata *block, const char *format, c snprintf(buffer, sizeof(buffer)-1, format, name, value); #endif setlocale(LC_ALL, saved_locale); + free(saved_locale); entry.entry = (FLAC__byte *)buffer; entry.length = strlen(buffer);