Skip to content

Commit 81378ba

Browse files
committed
ext/gmp: Use new parsing API in shift helper
1 parent 16acea4 commit 81378ba

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
@@ -419,25 +419,13 @@ static zend_result shift_operator_helper(gmp_binary_ui_op_t op, zval *return_val
419419
return FAILURE;
420420
} else {
421421
mpz_ptr gmpnum_op, gmpnum_result;
422-
gmp_temp_t temp;
423422

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

0 commit comments

Comments
 (0)