• 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: Where's the buffer overrun?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where's the buffer overrun?


  • Subject: Re: Where's the buffer overrun?
  • From: Chris Suter <email@hidden>
  • Date: Thu, 20 Mar 2008 11:18:49 +1100


On 20/03/2008, at 11:00 AM, Andrew Farmer wrote:

On 19 Mar 08, at 16:50, Chris Suter wrote:
On 20/03/2008, at 10:38 AM, Nick Zitzmann wrote:
char **returnArray = NSZoneMalloc([self zone], length);

should be:

char **returnArray = NSZoneMalloc([self zone], length * sizeof (char *));

Actually, that's correct. Read up a bit - length is already multiplied by the pointer size.

Sorry. A bit hasty in my response.

Maybe I can redeem myself.

I think it's because

[NSMutableData dataWithBytesNoCopy:returnArray length:length]

is releasing returnArray and allocating a new buffer for it. I'm guessing that's because it's NSMutableData.

To fix it, use NSData instead.

Kind regards,

Chris





_______________________________________________

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:
    • [SOLVED] Re: Where's the buffer overrun?
      • From: Nick Zitzmann <email@hidden>
    • Re: Where's the buffer overrun?
      • From: "Hamish Allan" <email@hidden>
References: 
 >Where's the buffer overrun? (From: Nick Zitzmann <email@hidden>)
 >Re: Where's the buffer overrun? (From: Chris Suter <email@hidden>)
 >Re: Where's the buffer overrun? (From: Andrew Farmer <email@hidden>)

  • Prev by Date: Re: Where's the buffer overrun?
  • Next by Date: Synchronous Ruby calls from Safari?
  • Previous by thread: Re: Where's the buffer overrun?
  • Next by thread: Re: Where's the buffer overrun?
  • Index(es):
    • Date
    • Thread