Skip to content

Commit

Permalink
Accept nil proc in Marshal.load. Fixes #4526.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Mar 9, 2017
1 parent 0c749ca commit 64c7ea0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyMarshal.java
Expand Up @@ -124,7 +124,7 @@ private static void setBinmodeIfPossible(ThreadContext context, IRubyObject io)
public static IRubyObject load(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
Ruby runtime = context.runtime;
IRubyObject in = args[0];
IRubyObject proc = args.length == 2 ? args[1] : null;
IRubyObject proc = args.length == 2 ? args[1] : context.nil;

try {
InputStream rawInput;
Expand Down
Expand Up @@ -77,6 +77,10 @@ public class UnmarshalStream extends InputStream {
private final boolean taint;

public UnmarshalStream(Ruby runtime, InputStream in, IRubyObject proc, boolean taint) throws IOException {
assert runtime != null;
assert in != null;
assert proc != null;

this.runtime = runtime;
this.cache = new UnmarshalCache(runtime);
this.proc = proc;
Expand Down Expand Up @@ -181,15 +185,15 @@ private static RubyModule getConstantFromPath(Ruby runtime, String path) {
}

private IRubyObject doCallProcForLink(IRubyObject result, int type) {
if (proc != null && type != ';') {
if (!proc.isNil() && type != ';') {
// return the result of the proc, but not for symbols
return Helpers.invoke(getRuntime().getCurrentContext(), proc, "call", result);
}
return result;
}

private IRubyObject doCallProcForObj(IRubyObject result) {
if (proc != null) {
if (!proc.isNil()) {
// return the result of the proc, but not for symbols
return Helpers.invoke(getRuntime().getCurrentContext(), proc, "call", result);
}
Expand Down

0 comments on commit 64c7ea0

Please sign in to comment.