summaryrefslogtreecommitdiffstats
path: root/libraries/libvmime-zarafa/zarafa-patches/vmime-plain-bodycopy.diff
blob: 6c1795d9699536178e945ceb5e3ebcdd5eed4ee6 (plain)
--- libvmime-0.7.1.orig/src/messageBuilder.cpp	2009-08-21 15:35:23.708082164 +0200
+++ libvmime-0.7.1/src/messageBuilder.cpp	2009-08-21 15:37:00.400088431 +0200
@@ -137,6 +137,8 @@
 	if (msg->getBody()->getPartCount() == 1)
 	{
 		const bodyPart& part = *msg->getBody()->getPartAt(0);
+		// make a full copy of the body, otherwise the copyFrom will delete the body we're copying
+		const body* bodyCopy = part.getBody()->clone();
 
 		// First, copy (and replace) the header fields
 		const std::vector <const headerField*> fields = part.getHeader()->getFieldList();
@@ -149,7 +151,8 @@
 
 		// 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);
+		delete bodyCopy;
 	}
 
 	return (msg);