aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2009-09-15 19:36:03 +0000
committerVincent Richard <[email protected]>2009-09-15 19:36:03 +0000
commitac6865fe365d03bc70f3257a795ecc8e18f2d85d (patch)
tree7d90cbe17903ac4569a2bbac1e2e989835561460
parentAdded workaround for Decider() for legacy versions of SCons. (diff)
downloadvmime-ac6865fe365d03bc70f3257a795ecc8e18f2d85d.tar.gz
vmime-ac6865fe365d03bc70f3257a795ecc8e18f2d85d.zip
Fixed possible segfault (thanks to John van der Kamp, from Zarafa).
-rw-r--r--src/messageBuilder.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/messageBuilder.cpp b/src/messageBuilder.cpp
index d6195547..a70372fb 100644
--- a/src/messageBuilder.cpp
+++ b/src/messageBuilder.cpp
@@ -142,6 +142,9 @@ ref <message> messageBuilder::construct() const
{
const bodyPart& part = *msg->getBody()->getPartAt(0);
+ // Make a full copy of the body, otherwise the copyFrom() will delete the body we're copying
+ ref <body> bodyCopy = part.getBody()->clone().dynamicCast <body>();
+
// First, copy (and replace) the header fields
const std::vector <ref <const headerField> > fields = part.getHeader()->getFieldList();
@@ -153,7 +156,7 @@ ref <message> messageBuilder::construct() const
// Second, copy the body contents and sub-parts (this also remove
// the body part we are copying...)
- msg->getBody()->copyFrom(*part.getBody());
+ msg->getBody()->copyFrom(*bodyCopy);
}
return (msg);