Commits

Ronald Oussoren committed 21f4702

This patches makes it possible to use objc.inject on Leopard (tested on
Intel systems, I expect it to work on PPC as well but don't have time to
test right now).

Comments (0)

Files changed (2)

pyobjc-core/Modules/objc/mach_inject.m

 				
 				// needed for Universal binaries. Check if file is fat and get image size from there.
 				int fd = open (imageName, O_RDONLY);
+				if (fd == -1) {
+					return unix_err(errno);
+				}
 				size_t mapSize = *size;
-				char * fileImage = mmap (NULL, mapSize, PROT_READ, MAP_FILE, fd, 0);
+				char * fileImage = mmap (NULL, mapSize, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0);
+				if (fileImage == (char*)-1) {
+					return unix_err(errno);
+				}
 				
 				struct fat_header* fatHeader = (struct fat_header *)fileImage;
 				if (fatHeader->magic == OSSwapBigToHostInt32(FAT_MAGIC)) {
 Version 2.0.1 (...)
 -------------------
 
+- BUGFIX: ``objc.inject`` works on Leopard (at least on Intel Macs, haven't
+  tested on PPC). 
+
 - BUGFIX: don't crash when printing CF objects that are magic cookies.
 
 - BUGFIX: It is now possible to override ``respondsToSelector:`` in Python.