diff options
-rw-r--r-- | Objective-C/libobjcl.m | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m index 3242fcf..993ebed 100644 --- a/Objective-C/libobjcl.m +++ b/Objective-C/libobjcl.m @@ -22,6 +22,7 @@ #import <Foundation/Foundation.h> #include <stdarg.h> +#include <sys/mman.h> #include <objc/objc-api.h> #ifdef __NEXT_RUNTIME__ @@ -484,15 +485,13 @@ objcl_slot_type (IVAR_T ivar) } - - /* In order to be able to do exception propagation from Lisp code, we have the Lisp layer save exceptions to objcl_current_exception. Our wrapper function is then able to raise the exception from where it ought to be raised from: the Objective-C layer. Note that it is the Lisp layer's duty to wrap Objective-C exceptions - around Lisp SERIOUS-CONDITIONs in order to propagate them. */ + around Lisp SERIOUS-CONDITIONs in order to propagate those. */ static void imp_closure (ffi_cif *cif, void *result, void **args, void *user_data) { @@ -556,6 +555,13 @@ objcl_create_imp (IMP callback, userInfo: nil] raise]; } + if (mprotect (closure, sizeof (closure), PROT_READ | PROT_EXEC) == -1) + { + [[NSException exceptionWithName: @"MLKClosureCreationFailure" + reason: @"Creating an IMP closure failed (this is probably a bug)." + userInfo: nil] raise]; + } + return (IMP) closure; } |