summaryrefslogtreecommitdiff
path: root/Objective-C
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-02-08 22:01:14 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-02-08 22:01:14 +0100
commita8c68aa48b01e609467d3295e0fdb63322b5ff69 (patch)
tree2ccd7a02ba2808c1abcc3220a9d26aa25cda83b7 /Objective-C
parent742c6f32e038c90967e15f4740fcdacda1ad0f1f (diff)
Objective-C layer: Use mprotect(2) where needed.
darcs-hash:46c7d60f049bc9c0a832bae5fcd9420d48ddfa5e
Diffstat (limited to 'Objective-C')
-rw-r--r--Objective-C/libobjcl.m12
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;
}