Skip to content
Browse files

Fix issue #612 - restrict struct parameters to those of the appropria…

…te type.
  • Loading branch information...
1 parent 303ec53 commit 6b3d6777efeb2ae7a193334e8d015e338e980423 Wayne Meissner committed Mar 29, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/org/jruby/ext/ffi/StructByReference.java
View
4 src/org/jruby/ext/ffi/StructByReference.java
@@ -77,14 +77,14 @@ public IRubyObject native_type(ThreadContext context) {
@JRubyMethod(name = "to_native")
public IRubyObject to_native(ThreadContext context, IRubyObject value, IRubyObject ctx) {
- if (value instanceof Struct) {
+ if (value instanceof Struct && structClass.isInstance(value)) {
return ((Struct) value).getMemory();
} else if (value.isNil()) {
return Pointer.getNull(context.runtime);
} else {
- throw context.runtime.newTypeError(value, context.runtime.getFFI().structClass);
+ throw context.runtime.newTypeError(value, structClass);
}
}

0 comments on commit 6b3d677

Please sign in to comment.
Something went wrong with that request. Please try again.