After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 771609 - Function manager: Check for 0-sized array of math functions when sorting
Function manager: Check for 0-sized array of math functions when sorting
Product: gnome-calculator
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gcalctool maintainers
gcalctool maintainers
Depends on:
Reported: 2016-09-18 04:47 UTC by Tobias Mueller
Modified: 2016-09-25 01:10 UTC
See Also:
GNOME target: ---
GNOME version: ---

patch (5.44 KB, patch)
2016-09-18 04:47 UTC, Tobias Mueller
committed Details | Review

Description Tobias Mueller 2016-09-18 04:47:00 UTC
Created attachment 335790 [details] [review]

Otherwise, array.length-1 will be 0-1 == -1.
And it'll try to access array[-1] which is not very good.
We prevent that by checking for the array size
and we're also asserting array index values to reference actual data
instead of pointing outside the array.

I found this with ASan when opening programming mode and clicking "ans" from
the "X" drop down box:
Comment 1 Robert Roth 2016-09-18 06:49:40 UTC
Review of attachment 335790 [details] [review]:

Seems sane, shouldn't break anything, only raise awareness of "broken" code, or index out of bounds.
Comment 2 Robert Roth 2016-09-25 01:09:54 UTC
Pushed to master.