Skip to content

Commit 92ff44d

Browse files
committed
ext/gmp: Use new parsing API in shift helper
1 parent 0831608 commit 92ff44d

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
@@ -427,25 +427,13 @@ static zend_result shift_operator_helper(gmp_binary_ui_op_t op, zval *return_val
427427
return FAILURE;
428428
} else {
429429
mpz_ptr gmpnum_op, gmpnum_result;
430-
gmp_temp_t temp;
431430

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

0 commit comments

Comments
 (0)