• 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: Casey Fleser <email@hidden>
  • Date: Fri, 6 Feb 2004 15:47:07 -0600

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.

Casey
_______________________________________________
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.

References: 
 >malloc in obj-c/cocoa (From: Ben Dougall <email@hidden>)

  • Prev by Date: Re: Are we still supposed to register Creator code (bundle signature) for OS X app?
  • Next by Date: Re: malloc in obj-c/cocoa
  • Previous by thread: Re: malloc in obj-c/cocoa
  • Next by thread: Re: malloc in obj-c/cocoa
  • Index(es):
    • Date
    • Thread