copy data delivered by ccnd before emit it to another thread
diff --git a/chatdialog.cpp b/chatdialog.cpp
index 70f67f5..7c354ad 100644
--- a/chatdialog.cpp
+++ b/chatdialog.cpp
@@ -357,7 +357,9 @@
 void
 ChatDialog::processDataWrapper(std::string name, const char *buf, size_t len)
 {
-  emit dataReceived(name.c_str(), buf, len, true);
+  char *tempBuf = new char[len];
+  memcpy(tempBuf, buf, len);
+  emit dataReceived(name.c_str(), tempBuf, len, true);
 #ifdef __DEBUG
   std::cout <<"<<< " << name << " fetched" << std::endl;
 #endif
@@ -366,7 +368,9 @@
 void
 ChatDialog::processDataNoShowWrapper(std::string name, const char *buf, size_t len)
 {
-  emit dataReceived(name.c_str(), buf, len, false);
+  char *tempBuf = new char[len];
+  memcpy(tempBuf, buf, len);
+  emit dataReceived(name.c_str(), tempBuf, len, false);
 }
 
 void
@@ -383,6 +387,9 @@
     corrupted = true;
   }
 
+  delete [] buf;
+  buf = NULL;
+
   // display msg received from network
   // we have to do so; this function is called by ccnd thread
   // so if we call appendMsg directly