diff options
author | Xinchen Hui <laruence@gmail.com> | 2020-05-15 15:36:51 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2020-05-15 15:36:51 +0800 |
commit | 446d189aa00dcca5eb66a78a26bb92cf8d919343 (patch) | |
tree | 0f6c47cde758609e3df3276027e2be33bf56cee9 | |
parent | ccd41e083359cf6dd264f88806dce4cc49d9358e (diff) | |
parent | 8c6d006b55bf5ba230dda672344dbd0e2a7d4be3 (diff) | |
download | php-git-446d189aa00dcca5eb66a78a26bb92cf8d919343.tar.gz |
Merge branch 'PHP-7.4' of git.php.net:/php-src into PHP-7.4
* 'PHP-7.4' of git.php.net:/php-src:
Fix #79557: extension_dir = ./ext now use current directory for base
Fix #79596: MySQL FLOAT truncates to int some locales
[ci skip] Fix NEWS
-rw-r--r-- | ext/mysqlnd/mysql_float_to_double.h | 4 | ||||
-rw-r--r-- | ext/pdo_mysql/tests/bug79596.phpt | 30 | ||||
-rw-r--r-- | win32/winutil.c | 8 |
3 files changed, 39 insertions, 3 deletions
diff --git a/ext/mysqlnd/mysql_float_to_double.h b/ext/mysqlnd/mysql_float_to_double.h index 0690a4c498..f9048d827c 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 { - sprintf(num_buf, "%.*f", decimals, fp4); + snprintf(num_buf, MAX_CHAR_BUF_LEN, "%.*F", decimals, fp4); } return zend_strtod(num_buf, NULL); diff --git a/ext/pdo_mysql/tests/bug79596.phpt b/ext/pdo_mysql/tests/bug79596.phpt new file mode 100644 index 0000000000..054e3c1c2e --- /dev/null +++ b/ext/pdo_mysql/tests/bug79596.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #79596 (MySQL FLOAT truncates to int some locales) +--SKIPIF-- +<?php +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc'); +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); +MySQLPDOTest::skip(); +if (!setlocale(LC_ALL, 'de_DE', 'de-DE')) die('skip German locale not available'); +?> +--FILE-- +<?php +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + +setlocale(LC_ALL, 'de_DE', 'de-DE'); + +$pdo = MySQLPDOTest::factory(); +$pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false); +$pdo->query('CREATE TABLE bug79596 (broken FLOAT(2,1))'); +$pdo->query('INSERT INTO bug79596 VALUES(4.9)'); +var_dump($pdo->query('SELECT broken FROM bug79596')->fetchColumn(0)); +?> +--CLEAN-- +<?php +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + +$pdo = MySQLPDOTest::factory(); +$pdo->exec("DROP TABLE IF EXISTS bug79596"); +?> +--EXPECT-- +float(4,9) diff --git a/win32/winutil.c b/win32/winutil.c index c04664bab3..8cf5cdc1e7 100644 --- a/win32/winutil.c +++ b/win32/winutil.c @@ -440,7 +440,13 @@ PHP_WINUTIL_API char *php_win32_get_username(void) static zend_always_inline BOOL is_compatible(const char *name, BOOL is_smaller, char *format, char **err) {/*{{{*/ - PLOADED_IMAGE img = ImageLoad(name, NULL); + /* work around ImageLoad() issue */ + char *name_stripped = name; + if (name[0] == '.' && IS_SLASH(name[1])) { + name_stripped += 2; + } + + PLOADED_IMAGE img = ImageLoad(name_stripped, NULL); if (!img) { DWORD _err = GetLastError(); |