• 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: malloc in obj-c/cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: malloc in obj-c/cocoa


  • Subject: Re: malloc in obj-c/cocoa
  • From: Ben Dougall <email@hidden>
  • Date: Fri, 6 Feb 2004 23:02:09 +0000

On Friday, February 6, 2004, at 09:47 pm, Casey Fleser wrote:

On Feb 6, 2004, at 3:14 PM, Ben Dougall wrote:

PositionPtr posp;
posp = (PositionPtr) malloc( i ));
while( i >= 0 ) {
*(posp + i) = *(Buffer + i);
i--;
}

Is i initialized here? Even if it is, it looks like you're writing past the end of the buffer you've allocated. You should malloc i+1 unless it is the length of your buffer and not the index of the last byte in which case you should predecrement i before entering your while loop.

yes i is initialised there and yes, one of my attempts did have i+1 - no difference - exactly the same error and backtrace etc, but i've readded the +1 now.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: malloc in obj-c/cocoa
      • From: Jens Bauer <email@hidden>
  • Prev by Date: Re: malloc in obj-c/cocoa
  • Next by Date: Re: Class variable?
  • Previous by thread: Re: malloc in obj-c/cocoa
  • Next by thread: Re: malloc in obj-c/cocoa
  • Index(es):
    • Date
    • Thread