Commit 4fcac0a
committed
Clamp comparisons to -1, 0, 1
fca9ae5 "avoid signed overflow" can still cause undefined behavior because
`compare_version_number` can return `INT_MIN` which `version_compare_cb_r`
then tries to negate:
```
../../../../ext/version_sorter/version_sorter.c:94:9: runtime error: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
#0 0x7f9cde1fe1ba in version_compare_cb_r /tmp/x86_64-linux-gnu/version_sorter/2.3.1/../../../../ext/version_sorter/version_sorter.c:94:9
#1 0x7f9cde75c231 (/lib/x86_64-linux-gnu/libc.so.6+0x39231)
#2 0x7f9cde75c69e in qsort_r (/lib/x86_64-linux-gnu/libc.so.6+0x3969e)
#3 0x7f9cde1fd68c in rb_version_sort_1 /tmp/x86_64-linux-gnu/version_sorter/2.3.1/../../../../ext/version_sorter/version_sorter.c:202:2
```1 parent fca9ae5 commit 4fcac0a
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
0 commit comments