Skip to content

Re-use ruby strings - #2

Merged
tmm1 merged 3 commits into
masterfrom
reuse-strings
Nov 15, 2012
Merged

Re-use ruby strings#2
tmm1 merged 3 commits into
masterfrom
reuse-strings

Conversation

@tmm1

@tmm1 tmm1 commented Nov 14, 2012

Copy link
Copy Markdown
Contributor

Avoids creating new ruby strings when returning a sorted array. This fixes an issue in 1.9 where a version string loses its encoding (and gets truncated if it has a null byte in it) when being sorted.

/cc @github/c-hackers @vmg @scottjg

tmm1 added a commit that referenced this pull request Nov 15, 2012
@tmm1
tmm1 merged commit 2bb4c19 into master Nov 15, 2012
mislav added a commit that referenced this pull request Feb 18, 2015
Handle integer overflow by treating number component as string if too large
@mislav
mislav deleted the reuse-strings branch February 18, 2015 03:14
kivikakk pushed a commit that referenced this pull request Feb 7, 2018
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
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant