diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-05-15 09:09:41 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-05-15 09:09:41 +0200 |
commit | d1cd489a53c697898c2da5101c775bd6259f4be0 (patch) | |
tree | bdbf92dd32c447635024fbe189d30a42dabc76b8 /ext/mysqlnd/mysql_float_to_double.h | |
parent | 5bdb4ab786b06dbf7ec4ece40b45f81287caba2d (diff) | |
download | php-git-d1cd489a53c697898c2da5101c775bd6259f4be0.tar.gz |
Fix #79596: MySQL FLOAT truncates to int some locales
We must not do locale aware float to string conversion here; instead
we using our `snprintf()` implementation with the `F` specifier.
Diffstat (limited to 'ext/mysqlnd/mysql_float_to_double.h')
-rw-r--r-- | ext/mysqlnd/mysql_float_to_double.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/mysqlnd/mysql_float_to_double.h b/ext/mysqlnd/mysql_float_to_double.h index 7ac77d9127..744d56a5f3 100644 --- a/ext/mysqlnd/mysql_float_to_double.h +++ b/ext/mysqlnd/mysql_float_to_double.h @@ -31,7 +31,7 @@ /* * Convert from a 4-byte float to a 8-byte decimal by first converting - * the float to a string, and then the string to a double. + * the float to a string (ignoring localization), and then the string to a double. * The decimals argument specifies the precision of the output. If decimals * is less than zero, then a gcvt(3) like logic is used with the significant * digits set to FLT_DIG i.e. 6. @@ -42,7 +42,7 @@ static inline double mysql_float_to_double(float fp4, int decimals) { if (decimals < 0) { php_gcvt(fp4, FLT_DIG, '.', 'e', num_buf); } else { - php_sprintf(num_buf, "%.*f", decimals, fp4); + snprintf(num_buf, MAX_CHAR_BUF_LEN, "%.*F", decimals, fp4); } return zend_strtod(num_buf, NULL); |