Re: malloc in obj-c/cocoa
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.