bookmarkDataWithContentsOfURL crashes
bookmarkDataWithContentsOfURL crashes
- Subject: bookmarkDataWithContentsOfURL crashes
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Mon, 7 Sep 2009 08:52:08 +0700
This code:
NSString *patx = @"/Volumes/เม่น/Users/gerriet/Downloads/abc
alias"; <--- this really is an alias, created in Finder.
NSURL *u2a = [ NSURL fileURLWithPath: patx ];
NSLog(@"%s will call bookmarkDataWithContentsOfURL",__FUNCTION__);
// the next line will create "malloc: *** error for object 0x1d20500:
double free" if it is an alias
// and soon after there will be a random crash
NSData *bookmarkData = [ NSURL bookmarkDataWithContentsOfURL: u2a
error: outError ];
NSLog(@"%s did call bookmarkDataWithContentsOfURL",__FUNCTION__);
if ( bookmarkData == nil ) // probably not a bookmark or alias
{
NSLog(@"%s not a bookmark %@",__FUNCTION__, *outError);
}
else
{
NSLog(@"%s is a bookmark \"%@\"",__FUNCTION__, patx);
};
results in:
... will call bookmarkDataWithContentsOfURL
GmdText(17333,0xa045b500) malloc: *** error for object 0x1e337b0:
double free
*** set a breakpoint in malloc_error_break to debug
(gdb) bt
#0 0x940ca28a in malloc_error_break ()
#1 0x940cb430 in szone_error ()
#2 0x940cb565 in free_tiny_botch ()
#3 0x90e62cac in _CFRelease ()
#4 0x94fd5e5e in _CFURLCreateBookmarkDataFromFile ()
#5 0x90f870a3 in +[NSURL bookmarkDataWithContentsOfURL:error:] ()
#6 0x0000765f in -[AppDelegate(AppDelegatePrivate)
openOneFile:error:] (self=0x1e1b790, _cmd=0x19d90, pat1=0x1c376c0,
outError=0xbfffe1a0) at /Volumes/เม่น /Users/gerriet/Source/
Stuff 10.2.0 RealProjects/GmdText-1.0/AppDelegate.m:2004
#7 0x000070a5 in -[AppDelegate openFile:userData:error:]
(self=0x1e1b790, _cmd=0x19e65, pboard=0x1c36e60, data=0xa011bca8,
outEroror=0xbfffe2a8) at /Volumes/เม่น /Users/gerriet/Source/
Stuff 10.2.0 RealProjects/GmdText-1.0/AppDelegate.m:1556
#8 0x9154aa55 in -[NSServiceListener
_doInvokeServiceIn:msg:pb:userData:error:unhide:] ()
#9 0x9154a513 in _NSServiceMasterCallBack ()
#10 0x90f521e9 in __CFServiceControllerMessagePortCallBack ()
#11 0x90f27323 in __CFMessagePortPerform ()
#12 0x90e97b8e in __CFRunLoopDoSource1 ()
#13 0x90e939e9 in __CFRunLoopRun ()
#14 0x90e91d34 in CFRunLoopRunSpecific ()
#15 0x90e91b61 in CFRunLoopRunInMode ()
#16 0x90039fec in RunCurrentEventLoopInMode ()
#17 0x90039da3 in ReceiveNextEventCommon ()
#18 0x90039c28 in BlockUntilNextEventMatchingListInMode ()
#19 0x91026b99 in _DPSNextEvent ()
#20 0x9102640e in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#21 0x90fe85fb in -[NSApplication run] ()
#22 0x90fe0695 in NSApplicationMain ()
#23 0x0000279a in main (argc=1, argv=0xbffff594) at /Volumes/
เม่น /Users/gerriet/Source/Stuff 10.2.0 RealProjects/
GmdText-1.0/main.m:5
(gdb) continue
... did call bookmarkDataWithContentsOfURL
... bookmarkData ok
and when I continue using this code (with different values of
"patx" (which point to bookmarks or not) I get random error messages
and crashes, so it seems this "double free" really did corrupt
something.
What did I do wrong?
Are there any better ways to resolve aliases? Or is the C-API the only
alternative?
Kind regards,
Gerriet.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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:
This email sent to email@hidden