• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSXMLParser frees itself on error?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSXMLParser frees itself on error?


  • Subject: Re: NSXMLParser frees itself on error?
  • From: Jesper Storm Bache <email@hidden>
  • Date: Fri, 1 May 2009 09:18:20 -0700

I have not used NSXMLParser, but as far as I can tell from your email, cleanupShowParsing is called in response to a call to the parser delegate.
In that case, you should not release the parser (because it is calling your delegate and is on the stack).
Try using autorelease instead.


Jesper Storm Bache

On Apr 30, 2009, at 11:59 PM, Mike Manzano wrote:

Hi Folks,

I have an NSXMLParser doing parsing the contents of a URL. It is
allocated like this:

	_showsParser = [[NSXMLParser alloc] initWithContentsOfURL:url];

Given a good URL to a parsable XML document, its parserDidEndDocument:
method calls this method:

- (void) cleanupShowParsing {
	[_buildingShows removeAllObjects];
	[_showsParser abortParsing];
	[_showsParser release];
	_showsParser = nil;
	_currentlyBuildingShows = NO;
}

Note that the parser is aborted and released in here. This seems to
work just fine, multiple times, with no problems. However, if I give
it a URL to non-XML data (should be a 404 page somewhere), it calls
parser:parseErrorOccurred: as expected. This method also calls -
cleanupShowParsing. However, when it is called from here, the program
eventually terminates with:

2009-04-30 23:53:52.573 Revision3[49280:20b] PARSE ERROR: Error
Domain=NSXMLParserErrorDomain Code=5 "Operation could not be
completed. (NSXMLParserErrorDomain error 5.)"
objc[49280]: FREED(id): message shouldContinueAfterFatalError sent to
freed object=0xf305a0

I have verified that 0xf305a0 is indeed _showsParser. Further, I've
verified that if I don't release _showsParser in -cleanupShowParsing,
no error occurs given a non-XML file.

My question is it the case that NSXMLParser frees itself if it
encounters an error, but does NOT free itself on a successful parse of
a document?

Thanks!

Mike<smime.p7s><ATT00001.txt>

_______________________________________________

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


  • Follow-Ups:
    • Re: NSXMLParser frees itself on error?
      • From: "Stephen J. Butler" <email@hidden>
References: 
 >NSXMLParser frees itself on error? (From: Mike Manzano <email@hidden>)

  • Prev by Date: Re: Threadsafe function help
  • Next by Date: Re: #import errors and @class warnings
  • Previous by thread: Re: NSXMLParser frees itself on error?
  • Next by thread: Re: NSXMLParser frees itself on error?
  • Index(es):
    • Date
    • Thread