Commit 9399747
authored
fix: prevent segfault in StringIO#seek with SEEK_END on null device (#137)
# Summary
Fixes segmentation fault when calling `seek` with `SEEK_END` on null
device StringIO created by
`StringIO.new(nil)`.
# How to Reproduce
```bash
ruby -e "require 'stringio'; StringIO.new(nil).seek(0, IO::SEEK_END)"
```
I tested with below versions.
```bash
[koh@Kohs-MacBook-Pro] ~
% ruby -v;gem info stringio;sw_vers
ruby 3.4.5 (2025-07-16 revision 20cda200d3) +PRISM [arm64-darwin24]
*** LOCAL GEMS ***
stringio (3.1.2)
Authors: Nobu Nakada, Charles Oliver Nutter
Homepage: https://github.com/ruby/stringio
Licenses: Ruby, BSD-2-Clause
Installed at (default): /Users/koh/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0
Pseudo IO on String
ProductName: macOS
ProductVersion: 15.5
BuildVersion: 24F74
[koh@Kohs-MacBook-Pro] ~
%
```1 parent 3c52ddc commit 9399747
File tree
3 files changed
+20
-2
lines changed- ext
- java/org/jruby/ext/stringio
- stringio
- test/stringio
3 files changed
+20
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1378 | 1378 | | |
1379 | 1379 | | |
1380 | 1380 | | |
1381 | | - | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
1382 | 1386 | | |
1383 | 1387 | | |
1384 | 1388 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
837 | 837 | | |
838 | 838 | | |
839 | 839 | | |
840 | | - | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
841 | 845 | | |
842 | 846 | | |
843 | 847 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
73 | 83 | | |
74 | 84 | | |
75 | 85 | | |
| |||
0 commit comments