Skip to content

Commit 0fc982e

Browse files
committed
ext/gmp: Use new parsing API in shift helper
1 parent 70d433f commit 0fc982e

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

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

0 commit comments

Comments
 (0)