mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
ext/pgsql: use smart_str_append_double() instead of snprintf call (#21406)
This commit is contained in:
committed by
GitHub
parent
ed887241be
commit
c658d3c787
@@ -5617,7 +5617,6 @@ static inline zend_result build_tablename(smart_str *querystr, PGconn *pg_link,
|
|||||||
PHP_PGSQL_API zend_result php_pgsql_insert(PGconn *pg_link, const zend_string *table, zval *var_array, zend_ulong opt, zend_string **sql)
|
PHP_PGSQL_API zend_result php_pgsql_insert(PGconn *pg_link, const zend_string *table, zval *var_array, zend_ulong opt, zend_string **sql)
|
||||||
{
|
{
|
||||||
zval *val, converted;
|
zval *val, converted;
|
||||||
char buf[256];
|
|
||||||
char *tmp;
|
char *tmp;
|
||||||
smart_str querystr = {0};
|
smart_str querystr = {0};
|
||||||
zend_result ret = FAILURE;
|
zend_result ret = FAILURE;
|
||||||
@@ -5700,7 +5699,7 @@ PHP_PGSQL_API zend_result php_pgsql_insert(PGconn *pg_link, const zend_string *t
|
|||||||
smart_str_append_long(&querystr, Z_LVAL_P(val));
|
smart_str_append_long(&querystr, Z_LVAL_P(val));
|
||||||
break;
|
break;
|
||||||
case IS_DOUBLE:
|
case IS_DOUBLE:
|
||||||
smart_str_appendl(&querystr, buf, snprintf(buf, sizeof(buf), "%F", Z_DVAL_P(val)));
|
smart_str_append_double(&querystr, Z_DVAL_P(val), 6, false);
|
||||||
break;
|
break;
|
||||||
case IS_NULL:
|
case IS_NULL:
|
||||||
smart_str_appendl(&querystr, "NULL", sizeof("NULL")-1);
|
smart_str_appendl(&querystr, "NULL", sizeof("NULL")-1);
|
||||||
@@ -5884,8 +5883,7 @@ static inline int build_assignment_string(PGconn *pg_link, smart_str *querystr,
|
|||||||
smart_str_append_long(querystr, Z_LVAL_P(val));
|
smart_str_append_long(querystr, Z_LVAL_P(val));
|
||||||
break;
|
break;
|
||||||
case IS_DOUBLE: {
|
case IS_DOUBLE: {
|
||||||
char buf[256];
|
smart_str_append_double(querystr, Z_DVAL_P(val), 6, false);
|
||||||
smart_str_appendl(querystr, buf, MIN(snprintf(buf, sizeof(buf), "%F", Z_DVAL_P(val)), sizeof(buf) - 1));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IS_NULL:
|
case IS_NULL:
|
||||||
|
|||||||
Reference in New Issue
Block a user