From 7d13c2dbf310d48aa11375e0c7adf769b45e68b0 Mon Sep 17 00:00:00 2001 From: tjr Date: Sat, 22 Feb 2003 00:06:05 +0000 Subject: Fix a bad free() call that would occur if some #if 0'd code was used. --- lib/libc/locale/wcstod.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/libc/locale/wcstod.c b/lib/libc/locale/wcstod.c index 51d8727..fbbe405 100644 --- a/lib/libc/locale/wcstod.c +++ b/lib/libc/locale/wcstod.c @@ -46,7 +46,7 @@ wcstod(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr) static const mbstate_t initial; mbstate_t state; double val; - char *buf, *end; + char *buf, *end, *p; const wchar_t *wcp; size_t clen, len; @@ -88,12 +88,14 @@ wcstod(const wchar_t * __restrict nptr, wchar_t ** __restrict endptr) #if 1 /* Fast, assume 1:1 WC:MBS mapping. */ *endptr = (wchar_t *)nptr + (end - buf); (void)clen; + (void)p; #else /* Slow, conservative approach. */ state = initial; *endptr = (wchar_t *)nptr; - while (buf < end && - (clen = mbrlen(buf, end - buf, &state)) > 0) { - buf += clen; + p = buf; + while (p < end && + (clen = mbrlen(p, end - p, &state)) > 0) { + p += clen; (*endptr)++; } #endif -- cgit v1.1