Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Rendering a CTCoreMessage more than once causes segfault. #36

Closed
ghdk opened this Issue Sep 4, 2012 · 1 comment

Comments

Projects
None yet
3 participants
Contributor

ghdk commented Sep 4, 2012

The call to mailmime_free introduced in the changeset 4a7a6f8 causes a segfault when render is called on the same CTCoreMessage more than once. The problem seems to be that the call to free destroys the myFields of CTMIME_MessagePart. The sequence of instructions within CTMIME render method is

  1. [self buildMIMEStruct]
  2. mailmime_set_imf_fields(mime, myFields) which does
    build_info->mm_data.mm_message.mm_fields = mm_fields
    ....
  3. mailmime_free (mime) which frees
    mailimf_fields_free(mime->mm_data.mm_message.mm_fields)

I set the fields to NULL as shown bellow before the call to free, and the issue went away, however i am not sure whether that is an acceptable solution.

diff --git a/Source/CTMIME.m b/Source/CTMIME.m
index 9e2ed9b..1a1a4d6 100644
--- a/Source/CTMIME.m
+++ b/Source/CTMIME.m
@@ -112,6 +112,7 @@
     resultStr = [[NSString alloc] initWithBytes:str->str length:str->len
                     encoding:NSUTF8StringEncoding];
     mmap_string_free(str);
+    mime->mm_data.mm_message.mm_fields = NULL;
     mailmime_free(mime);
     return [resultStr autorelease];
 }

JanC commented Sep 21, 2012

Hi,
I've just updated my MailCore sources and I'm having the same problem. Setting the mm_fields to NULL does not help though.

@mronge mronge closed this Nov 20, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment