Skip to content

Commit 31c65da

Browse files
committed
ext/gmp: Use zend_string to GMP object function directly
1 parent aa559f0 commit 31c65da

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/gmp/gmp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ if (IS_GMP(zval)) { \
179179
gmp_create(return_value, &gmpnumber)
180180

181181
static void gmp_strval(zval *result, mpz_t gmpnum, int base);
182+
static zend_result convert_zstr_to_gmp(mpz_t gmp_number, const zend_string *val, zend_long base, uint32_t arg_pos);
182183
static zend_result convert_to_gmp(mpz_t gmpnumber, zval *val, zend_long base, uint32_t arg_pos);
183184
static void gmp_cmp(zval *return_value, zval *a_arg, zval *b_arg, bool is_operator);
184185

@@ -493,7 +494,7 @@ static int gmp_unserialize(zval *object, zend_class_entry *ce, const unsigned ch
493494
zv = var_tmp_var(&unserialize_data);
494495
if (!php_var_unserialize(zv, &p, max, &unserialize_data)
495496
|| Z_TYPE_P(zv) != IS_STRING
496-
|| convert_to_gmp(gmpnum, zv, 10, 0) == FAILURE
497+
|| convert_zstr_to_gmp(gmpnum, Z_STR_P(zv), 10, 0) == FAILURE
497498
) {
498499
zend_throw_exception(NULL, "Could not unserialize number", 0);
499500
goto exit;
@@ -2108,7 +2109,7 @@ ZEND_METHOD(GMP, __unserialize)
21082109

21092110
zval *num = zend_hash_index_find(data, 0);
21102111
if (!num || Z_TYPE_P(num) != IS_STRING ||
2111-
convert_to_gmp(GET_GMP_FROM_ZVAL(ZEND_THIS), num, 16, 0) == FAILURE) {
2112+
convert_zstr_to_gmp(GET_GMP_FROM_ZVAL(ZEND_THIS), Z_STR_P(num), 16, /* arg_pos */ 0) == FAILURE) {
21122113
zend_throw_exception(NULL, "Could not unserialize number", 0);
21132114
RETURN_THROWS();
21142115
}

0 commit comments

Comments
 (0)