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