Skip to content

Commit

Permalink
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions core/src/main/java/org/jruby/runtime/marshal/UnmarshalStream.java
Original file line number Diff line number Diff line change
@@ -285,16 +285,19 @@ private IRubyObject unmarshalObjectDirectly(int type, MarshalState state, boolea
}

private IRubyObject unmarshalRegexp(MarshalState state) throws IOException {
IRubyObject rubyObj;ByteList byteList = unmarshalString();
ByteList byteList = unmarshalString();
byte opts = readSignedByte();
RegexpOptions reOpts = RegexpOptions.fromJoniOptions(opts);

IRubyObject ivarHolder = null;

if (state.isIvarWaiting()) {
RubyString tmpStr = RubyString.newString(runtime, byteList);
registerLinkTarget(tmpStr);
defaultVariablesUnmarshal(tmpStr);
byteList = tmpStr.getByteList();
state.setIvarWaiting(false);
ivarHolder = tmpStr;
}
if (byteList.getEncoding() == ASCIIEncoding.INSTANCE) {
/* 1.8 compatibility; remove escapes undefined in 1.8 */
@@ -348,8 +351,15 @@ private IRubyObject unmarshalRegexp(MarshalState state) throws IOException {
byteList.setRealSize(dst - ptr);
}

rubyObj = RubyRegexp.newRegexp(runtime, byteList, reOpts);
return rubyObj;
RubyRegexp regexp = RubyRegexp.newRegexp(runtime, byteList, reOpts);

if (ivarHolder != null) {
ivarHolder.getInstanceVariables().copyInstanceVariablesInto(regexp);
}

registerLinkTarget(regexp);

return regexp;
}

public Ruby getRuntime() {

0 comments on commit d9dd559

Please sign in to comment.