Skip to content

Commit 7858934

Browse files
committed
ext/gmp: Use new parsing API in shift helper
1 parent 4b2d9ff commit 7858934

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

ext/gmp/gmp.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -423,25 +423,13 @@ static zend_result shift_operator_helper(gmp_binary_ui_op_t op, zval *return_val
423423
return FAILURE;
424424
} else {
425425
mpz_ptr gmpnum_op, gmpnum_result;
426-
gmp_temp_t temp;
427426

428-
/* We do not use FETCH_GMP_ZVAL(...); here as we don't use convert_to_gmp()
429-
* as we want to handle the emitted exception ourself. */
430-
if (UNEXPECTED(!IS_GMP(op1))) {
431-
if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) {
432-
goto typeof_op_failure;
433-
}
434-
mpz_init(temp.num);
435-
mpz_set_si(temp.num, Z_LVAL_P(op1));
436-
temp.is_used = 1;
437-
gmpnum_op = temp.num;
438-
} else {
439-
gmpnum_op = GET_GMP_FROM_ZVAL(op1);
440-
temp.is_used = 0;
427+
if (!gmp_zend_parse_arg_into_mpz_ex(op1, &gmpnum_op, 1, true)) {
428+
goto typeof_op_failure;
441429
}
430+
442431
INIT_GMP_RETVAL(gmpnum_result);
443432
op(gmpnum_result, gmpnum_op, (gmp_ulong) shift);
444-
FREE_GMP_TEMP(temp);
445433
return SUCCESS;
446434
}
447435

0 commit comments

Comments
 (0)