Revision: 7427
          http://mahogany.svn.sourceforge.net/mahogany/?rev=7427&view=rev
Author:   vadz
Date:     2008-04-24 15:05:08 -0700 (Thu, 24 Apr 2008)

Log Message:
-----------
don't reuse old pointer in GetContent() unless we own it: otherwise it points 
into a c-client per-stream buffer which could have been overwritten by another 
operation on the mailbox

Modified Paths:
--------------
    trunk/M/src/mail/MimePartCCBase.cpp

Modified: trunk/M/src/mail/MimePartCCBase.cpp
===================================================================
--- trunk/M/src/mail/MimePartCCBase.cpp 2008-04-23 02:26:41 UTC (rev 7426)
+++ trunk/M/src/mail/MimePartCCBase.cpp 2008-04-24 22:05:08 UTC (rev 7427)
@@ -317,21 +317,28 @@
 
 const void *MimePartCCBase::GetContent(unsigned long *lenptr) const
 {
-   // first check if we don't already have it
-   if ( m_content )
+   MimePartCCBase * const self = const_cast<MimePartCCBase *>(this);
+
+   if ( m_ownsContent )
    {
+      ASSERT_MSG( m_content, "must have some content to own" );
+
+      // if we have the old contents pointer which we own, we can be simply
+      // reuse it
       *lenptr = m_lenContent;
 
       return m_content;
    }
+   //else: if we don't own the content, we can't suppose that it's valid even
+   //      if it's non-NULL because it's a pointer into a per-stream (in
+   //      c-client sense) buffer and so could be overwritten by an operation
+   //      on another part
 
-   // no, get the raw text
    const void *cptr = GetRawContent(lenptr);
    if ( !cptr || !*lenptr )
       return NULL;
 
-   // and decode it
-   return const_cast<MimePartCCBase *>(this)->DecodeRawContent(cptr, lenptr);
+   return self->DecodeRawContent(cptr, lenptr);
 }
 
 const void *


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to