Skip to content

Commit a3c04c3

Browse files
committed
wip
1 parent 54f798a commit a3c04c3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ext/bcmath/bcmath.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,14 +852,15 @@ static zend_result bc_num_calculation(zval *result, zval *op1, zval *op2, bc_num
852852
{
853853
bc_num num1, num2;
854854
bc_num_obj *result_obj;
855-
bool should_free1, should_free2;
855+
bool should_free1, should_free2, should_free_result = false;
856856

857857
if (convert_zval_to_bc_num(op1, &num1, &should_free1) == FAILURE || convert_zval_to_bc_num(op2, &num2, &should_free2) == FAILURE) {
858858
goto cleanup;
859859
}
860860

861861
result_obj = bc_num_obj_from_obj(bc_num_create_obj(bc_num_ce));
862862
bc_init_num(&result_obj->bc_num);
863+
should_free_result = true;
863864

864865
size_t scale = MAX(num1->n_scale, num2->n_scale);
865866

@@ -910,7 +911,9 @@ static zend_result bc_num_calculation(zval *result, zval *op1, zval *op2, bc_num
910911
if (should_free2) {
911912
bc_free_num(&num2);
912913
}
913-
bc_free_num(&result_obj->bc_num);
914+
if (should_free_result) {
915+
bc_free_num(&result_obj->bc_num);
916+
}
914917
return FAILURE;
915918
}
916919

0 commit comments

Comments
 (0)