Skip to content

Commit c658d3c

Browse files
authored
ext/pgsql: use smart_str_append_double() instead of snprintf call (#21406)
1 parent ed88724 commit c658d3c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

ext/pgsql/pgsql.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5617,7 +5617,6 @@ static inline zend_result build_tablename(smart_str *querystr, PGconn *pg_link,
56175617
PHP_PGSQL_API zend_result php_pgsql_insert(PGconn *pg_link, const zend_string *table, zval *var_array, zend_ulong opt, zend_string **sql)
56185618
{
56195619
zval *val, converted;
5620-
char buf[256];
56215620
char *tmp;
56225621
smart_str querystr = {0};
56235622
zend_result ret = FAILURE;
@@ -5700,7 +5699,7 @@ PHP_PGSQL_API zend_result php_pgsql_insert(PGconn *pg_link, const zend_string *t
57005699
smart_str_append_long(&querystr, Z_LVAL_P(val));
57015700
break;
57025701
case IS_DOUBLE:
5703-
smart_str_appendl(&querystr, buf, snprintf(buf, sizeof(buf), "%F", Z_DVAL_P(val)));
5702+
smart_str_append_double(&querystr, Z_DVAL_P(val), 6, false);
57045703
break;
57055704
case IS_NULL:
57065705
smart_str_appendl(&querystr, "NULL", sizeof("NULL")-1);
@@ -5884,8 +5883,7 @@ static inline int build_assignment_string(PGconn *pg_link, smart_str *querystr,
58845883
smart_str_append_long(querystr, Z_LVAL_P(val));
58855884
break;
58865885
case IS_DOUBLE: {
5887-
char buf[256];
5888-
smart_str_appendl(querystr, buf, MIN(snprintf(buf, sizeof(buf), "%F", Z_DVAL_P(val)), sizeof(buf) - 1));
5886+
smart_str_append_double(querystr, Z_DVAL_P(val), 6, false);
58895887
}
58905888
break;
58915889
case IS_NULL:

0 commit comments

Comments
 (0)