From 18fec1e9c1eeaf2f598b98aa764c161fee1f91d9 Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Fri, 18 May 2012 12:57:38 +0200 Subject: [PATCH] Bug#14039955 RPAD FUNCTION LEADS TO UNINITIALIZED VALUES WARNING IN MY_STRTOD Rewrite the "parser" in my_strtod_int() to avoid reading past the end of the input string. --- strings/dtoa.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/strings/dtoa.c b/strings/dtoa.c index ef1c141ec44..4086bf412fe 100644 --- a/strings/dtoa.c +++ b/strings/dtoa.c @@ -1416,20 +1416,27 @@ static double my_strtod_int(const char *s00, char **se, int *error, char *buf, s c= *++s; if (!nd) { - for (; s < end && c == '0'; c= *++s) + for (; s < end; ++s) + { + c= *s; + if (c != '0') + break; nz++; + } if (s < end && c > '0' && c <= '9') { s0= s; nf+= nz; nz= 0; - goto have_dig; } - goto dig_done; + else + goto dig_done; } - for (; s < end && c >= '0' && c <= '9'; c = *++s) + for (; s < end; ++s) { - have_dig: + c= *s; + if (c < '0' || c > '9') + break; /* Here we are parsing the fractional part. We can stop counting digits after a while: the extra digits