Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions core/src/main/java/org/jruby/util/Pack.java
Original file line number Diff line number Diff line change
Expand Up @@ -1008,12 +1008,11 @@ private static IRubyObject unpackInternal(ThreadContext context, RubyString enco
int len = encodedString.realSize();
int beg = encodedString.begin();

if (offset < 0) throw argumentError(context, "offset can't be negative");
if (offset > 0) {
if (offset > len) throw argumentError(context, "offset outside of string");
beg += offset;
len -= offset;
if (offset < 0 ? (offset += len) < 0 : offset > len) {
throw argumentError(context, "offset outside of string");
}
beg += (int) offset;
len -= (int) offset;
final int alignBase = (int) offset;


Expand Down
2 changes: 2 additions & 0 deletions test/mri/excludes/TestPack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
exclude :test_pack_unpack_bB, "needs investigation"
exclude :test_pack_unpack_u, "needs investigation"
exclude :test_short_with_block, "needs investigation"
exclude :test_unpack1_offset, "expects the pre-4.1 error for a negative offset (Feature #21979); needs a test_pack.rb sync from CRuby"
exclude :test_unpack_offset, "expects the pre-4.1 error for a negative offset (Feature #21979); needs a test_pack.rb sync from CRuby"
Loading