GNOME Bugzilla – Bug 771609
Function manager: Check for 0-sized array of math functions when sorting
Last modified: 2016-09-25 01:10:02 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:
Review of attachment 335790 [details] [review]:
Seems sane, shouldn't break anything, only raise awareness of "broken" code, or index out of bounds.
Pushed to master.