• 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: Correct Order for CFRelease-ing CFNetwork Refs?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Correct Order for CFRelease-ing CFNetwork Refs?


  • Subject: Re: Correct Order for CFRelease-ing CFNetwork Refs?
  • From: "Kyle Sluder" <email@hidden>
  • Date: Tue, 1 Jul 2008 13:09:01 -0400

On Tue, Jul 1, 2008 at 9:09 AM, Jonathan Hohle <email@hidden> wrote:
> I recently wrote some code to retrieve data from an NTLM authenticated web
> server. As far as I can tell NTLM isn't supported at the Cocoa level, so I
> used CFNetwork to make the request. The example docs were clear and helpful,
> but I couldn't find anything on deallocating a CFHTTPAuthenticationRef.

There won't be any documentation regarding allocating and deallocating
most objects, because, like Cocoa, Core Foundation religiously follows
a memory management scheme known as the Create Rule.

> The example code saves off the CFHTTPAuthenticationRef for reuse, a pattern
> which I followed. In my -dealloc method, I was calling CFRelease with the
> request ref (which may or may not have an authentication ref applied to it),
> followed by CFRelease with the authentication ref. This consistently crashed
> with EXC_BAD_ACCESS. By chance, I switched the order, and now the code works
> without crashing.

How did you create your auth ref?
CFHTTPAuthenticationCreateFromResponse?  It seems that you have
forgotten to CFRetain it (when you store it somewhere is the most
likely place) and freeing the request is releasing the auth ref which
is also being freed.

--Kyle Sluder
_______________________________________________

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: Correct Order for CFRelease-ing CFNetwork Refs?
      • From: "Michael Ash" <email@hidden>
    • Re: Correct Order for CFRelease-ing CFNetwork Refs?
      • From: mmalc crawford <email@hidden>
References: 
 >Correct Order for CFRelease-ing CFNetwork Refs? (From: Jonathan Hohle <email@hidden>)

  • Prev by Date: Re: exec(uting) Safari - How (newbie)
  • Next by Date: Re: Flowcharts in Cocoa
  • Previous by thread: Correct Order for CFRelease-ing CFNetwork Refs?
  • Next by thread: Re: Correct Order for CFRelease-ing CFNetwork Refs?
  • Index(es):
    • Date
    • Thread