From 3998ca512f85580b18b2feea6743389b596e072a Mon Sep 17 00:00:00 2001 From: Laurent Sansonetti Date: Fri, 27 May 2011 15:36:06 -0700 Subject: [PATCH] don't crash when messaging methodSignatureForSelector: to NSProxy class or instance --- objc.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/objc.m b/objc.m index e71087b23..a7b243b83 100644 --- a/objc.m +++ b/objc.m @@ -103,7 +103,14 @@ rb_objc_supports_forwarding(VALUE recv, SEL sel) { if (!SPECIAL_CONST_P(recv)) { - return [(id)recv methodSignatureForSelector:sel] != nil; + @try { + // Protect the call since it may throw an exception when called on + // NSProxy class or instance. + return [(id)recv methodSignatureForSelector:sel] != nil; + } + @catch (id exc) { + return false; + } } return false; }