fix memory management error

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36556 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2013-04-22 10:27:07 +00:00
parent fde2622afa
commit 6dad554c51
2 changed files with 15 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2013-04-22 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSMime.m: Fix memory management error with excess bytes
after parsing mime headers.
2013-04-18 Marcus Muller <znek@mulle-kybernetik.com>
* Source/NSMetadata.m: Fix to expose variables to compiler building

View file

@ -1540,7 +1540,7 @@ wordData(NSString *word)
r = [self _endOfHeaders: d];
if (r.location == NSNotFound)
{
[data appendData: d];
[data appendBytes: [d bytes] length: [d length]];
bytes = (unsigned char*)[data bytes];
dataEnd = [data length];
/* Fall through to parse the headers so far.
@ -1556,6 +1556,9 @@ wordData(NSString *word)
dataEnd = [data length];
if (l > i)
{
/* NB. Take care ... the data object we create does not own or
* free its storage.
*/
d = [[[NSData alloc] initWithBytesNoCopy: (void*)([d bytes] + i)
length: l - i
freeWhenDone: NO] autorelease];
@ -1653,7 +1656,12 @@ wordData(NSString *word)
*/
if ([d length] > 0)
{
ASSIGNCOPY(boundary, d);
/* NB. We must copy the bytes from 'd' as that object doesn't
* own its storage.
*/
RELEASE(boundary);
boundary = [[NSData alloc] initWithBytes: [d bytes]
length: [d length]];
flags.excessData = 1;
}
}