From: Ben Pfaff Date: Tue, 25 Nov 2008 06:12:01 +0000 (-0800) Subject: Fix memory leak in get_system_decimal(). X-Git-Tag: v0.7.1~50^2~8^2 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a4735195d1915fa25be69ea13b9591813dbc978;p=pspp-builds.git Fix memory leak in get_system_decimal(). --- diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c index bda2676c..db851217 100644 --- a/src/libpspp/i18n.c +++ b/src/libpspp/i18n.c @@ -225,24 +225,24 @@ i18n_done (void) char get_system_decimal (void) { - char *radix_char = NULL; + char radix_char; char *ol = setlocale (LC_NUMERIC, NULL); setlocale (LC_NUMERIC, ""); #if HAVE_NL_LANGINFO - radix_char = nl_langinfo (RADIXCHAR); + radix_char = nl_langinfo (RADIXCHAR)[0]; #else { - char *buf = xmalloc (10); - snprintf (buf, 10, "%f", 2.5); - radix_char = &buf[1]; + char buf[10]; + snprintf (buf, sizeof buf, "%f", 2.5); + radix_char = buf[1]; } #endif /* We MUST leave LC_NUMERIC untouched, since it would otherwise interfere with data_{in,out} */ setlocale (LC_NUMERIC, ol); - return *radix_char; + return radix_char; }