Skip to content

Commit

Permalink
Merge pull request Alinto#14 from Zentyal/ejhernandez/fix-memory-leak…
Browse files Browse the repository at this point in the history
…-when-non-decoding-quoted-printable

 Fix memory leak when failing to parse a quoted printable
  • Loading branch information
extrafu committed Nov 27, 2014
2 parents e2a278e + 75bd8a0 commit efe09d6
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions sope-core/NGExtensions/NGQuotedPrintableCoding.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,17 @@ - (NSData *)dataByDecodingQuotedPrintable {
resSize =
NGDecodeQuotedPrintableX([self bytes], [self length], dest, destSize, YES);

return ((int)resSize != -1)
? [NSData dataWithBytesNoCopy:dest length:resSize]
: nil;
if ((int)resSize != -1)
{
return [NSData dataWithBytesNoCopy:dest length:resSize];
}
else
{
free(dest);
return nil;
}
}

- (NSData *)dataByDecodingQuotedPrintableTransferEncoding {
char *dest;
size_t destSize;
Expand All @@ -87,9 +94,15 @@ - (NSData *)dataByDecodingQuotedPrintableTransferEncoding {
resSize =
NGDecodeQuotedPrintableX([self bytes], [self length], dest, destSize, NO);

return ((int)resSize != -1)
? [NSData dataWithBytesNoCopy:dest length:resSize]
: nil;
if ((int)resSize != -1)
{
return [NSData dataWithBytesNoCopy:dest length:resSize];
}
else
{
free(dest);
return nil;
}
}

- (NSData *)dataByEncodingQuotedPrintable {
Expand Down

0 comments on commit efe09d6

Please sign in to comment.