Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa called from Carbon, objc_msgSend crash in 10.3.9.



Even if there is a vtable, I suspect that this would technically work because the vtable shows up at (Byte*)this - sizeof(void*).
I agree that it is skanky, though... unless his class implements an operator uint16*, in which case it is fine. If the class doesn't already include this operator, it should be added right away for safety.



On Dec 18, 2006, at 2:52 PM, David Duncan wrote:

On Dec 18, 2006, at 2:28 PM, Matt Fox-Wilson wrote:

gCString sResult = L"";
UniChar* sSource = (UniChar*)(uint16*)sRef;

This may not actually be a problem, but it is relying on the internal layout of your class to function properly (I'm assuming sRef is another instance of a gCString?). Unless the UniChar buffer is inline at the start of this class and there are no virtual functions, this shouldn't work. All of that may even be true, but I wouldn't rely on it and it would probably be very useful to add a UniCharPtr() accessor to your class that just returns a UniChar* to your characters.


if (sRef.Length() < 1) return sResult;

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString * nsSrc = [NSString stringWithCharacters:sSource length:sRef.Length()];


NSString* nsExt = [nsSrc lastPathComponent];
sResult.CopyString((CFStringRef)nsExt);

return sResult;

-- David Duncan Apple DTS Quartz and Printing email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jstiles% 40blizzard.com


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Cocoa called from Carbon, objc_msgSend crash in 10.3.9. (From: "Matt Fox-Wilson" <email@hidden>)
 >Re: Cocoa called from Carbon, objc_msgSend crash in 10.3.9. (From: David Duncan <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.