]> granicus.if.org Git - php/commitdiff
Cleanup type conversion
authorDmitry Stogov <dmitry@zend.com>
Thu, 7 Dec 2017 19:01:41 +0000 (22:01 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 7 Dec 2017 19:01:41 +0000 (22:01 +0300)
ext/mysqlnd/mysqlnd_ps_codec.c
ext/xsl/xsltprocessor.c

index c61bb30edb4693555becf36aca21fb3585129161..c5cc5c96cbb65644b6c7b79893220dcb7709a7b6 100644 (file)
@@ -600,23 +600,19 @@ mysqlnd_stmt_execute_prepare_param_types(MYSQLND_STMT_DATA * stmt, zval ** copie
                                  to losing precision we need second variable. Conversion to double is to see if
                                  value is too big for a long. As said, precision could be lost.
                                */
-                               zval tmp_data_copy;
-                               ZVAL_COPY(&tmp_data_copy, tmp_data);
-                               convert_to_double_ex(&tmp_data_copy);
+                               double d = zval_get_double(tmp_data);
 
                                /*
                                  if it doesn't fit in a long send it as a string.
                                  Check bug #52891 : Wrong data inserted with mysqli/mysqlnd when using bind_param, value > LONG_MAX
                                  We do transformation here, which will be used later when sending types. The code later relies on this.
                                */
-                               if (Z_DVAL(tmp_data_copy) > ZEND_LONG_MAX || Z_DVAL(tmp_data_copy) < ZEND_LONG_MIN) {
+                               if (d > ZEND_LONG_MAX || d < ZEND_LONG_MIN) {
                                        stmt->send_types_to_server = *resend_types_next_time = 1;
                                        convert_to_string_ex(tmp_data);
                                } else {
-                                       convert_to_long_ex(tmp_data);
+                                       convert_to_long(tmp_data);
                                }
-
-                               zval_ptr_dtor(&tmp_data_copy);
                        }
                }
        }
index 5fe6c614940d60fff46135d756975cc8453ade81..94100dfc991c0df0c21411c0975279adbce638f2 100644 (file)
@@ -801,8 +801,7 @@ PHP_FUNCTION(xsl_xsltprocessor_get_parameter)
        }
        intern = Z_XSL_P(id);
        if ((value = zend_hash_find(intern->parameter, name)) != NULL) {
-               convert_to_string_ex(value);
-               RETURN_STR_COPY(Z_STR_P(value));
+               RETURN_STR(zval_get_string(value));
        } else {
                RETURN_FALSE;
        }