mate-desktop / mate-calc

Calculator for MATE
http://www.mate-desktop.org
GNU General Public License v2.0
39 stars 33 forks source link

mp.c: mp_reciprocal: fix when calling it with same arguments. #188

Closed mbkma closed 3 years ago

mbkma commented 3 years ago

The z value was set to 1, which is the same as the x value if both addresses x and z are equal. Thus, the final value of z was 1/1=1. Solved by making a temp variable.

No need to backport, because culprit b0117b1d5ae73916c6f0d289be1f693bb5f46824 is not in the 1.24 branch.

raveit65 commented 3 years ago

How can this be tested? Before? After? :)

mbkma commented 3 years ago

For example this fixes currency conversion (was broken by b0117b1d5ae73916c6f0d289be1f693bb5f46824) because mp_reciprocal is used in currency manager:

$ grep -r mp_reciprocal
src/currency-manager.c:                    mp_reciprocal(&value, &value);

Test: Before: (most currencies are equally valuable) Screenshot at 2021-03-06 20-37-00 After: (most currencies are different) Screenshot at 2021-03-06 20-41-39