From a8c68aa48b01e609467d3295e0fdb63322b5ff69 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Fri, 8 Feb 2008 22:01:14 +0100 Subject: Objective-C layer: Use mprotect(2) where needed. darcs-hash:46c7d60f049bc9c0a832bae5fcd9420d48ddfa5e --- Objective-C/libobjcl.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Objective-C') 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 #include +#include #include #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; } -- cgit v1.2.3