Skip to content

Commit 0ff1d89

Browse files
committed
Address code review
1 parent a5e4764 commit 0ff1d89

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

Zend/zend_operators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(zval *op) /* {{{ */
816816
} else {
817817
/* Previously we used strtol here, not is_numeric_string,
818818
* and strtol gives you LONG_MAX/_MIN on overflow.
819-
* We use use saturating conversion to emulate strtol()'s
819+
* We use saturating conversion to emulate strtol()'s
820820
* behaviour.
821821
*/
822822
return zend_dval_to_lval_cap(dval);

ext/mysqli/mysqli_api.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,15 +1706,29 @@ PHP_FUNCTION(mysqli_options)
17061706
#endif
17071707
expected_type = mysqli_options_get_option_zval_type(mysql_option);
17081708
if (expected_type == IS_STRING) {
1709+
bool is_long_arg = 0;
17091710
if (!mysql_value_str) {
1710-
zend_argument_type_error(3, "must be of type string for the chosen option");
1711-
RETURN_THROWS();
1711+
mysql_value_str = zend_long_to_str(mysql_value_long);
1712+
is_long_arg = 1;
17121713
}
17131714
ret = mysql_options(mysql->mysql, mysql_option, ZSTR_VAL(mysql_value_str));
1715+
1716+
if (is_long_arg) {
1717+
zend_string_release(mysql_value_str);
1718+
}
17141719
} else if (expected_type == IS_LONG) {
17151720
if (mysql_value_str) {
1716-
zend_argument_type_error(3, "must be of type int for the chosen option");
1717-
RETURN_THROWS();
1721+
double rv;
1722+
zend_long lv;
1723+
zend_uchar type;
1724+
1725+
type = is_numeric_string(ZSTR_VAL(mysql_value_str), ZSTR_LEN(mysql_value_str), &lv, &rv, 0);
1726+
if (type == IS_LONG) {
1727+
mysql_value_long = lv;
1728+
} else {
1729+
zend_argument_type_error(getThis() ? 1 : 2, "must be a numeric string for the chosen option");
1730+
RETURN_THROWS();
1731+
}
17181732
}
17191733
ret = mysql_options(mysql->mysql, mysql_option, (char *) &mysql_value_long);
17201734
} else {

0 commit comments

Comments
 (0)