Blob Blame History Raw
commit 0f9f942a5bbe0ed9f07ea2e1fef90a7e2db768e5
Author: Paul Cornett <paulcor@users.noreply.github.com>
Date:   Fri Oct 2 09:14:06 2015 -0700

    Fix memory leak introduced in 8f29de52
    
    Also, use memcpy() instead of strcpy() since we already have the length,
    and use static_cast instead of reinterpret_cast.

diff --git a/src/gtk/dataobj.cpp b/src/gtk/dataobj.cpp
index 2d1f43c..df460d8 100644
--- a/src/gtk/dataobj.cpp
+++ b/src/gtk/dataobj.cpp
@@ -235,7 +235,7 @@ wxTextDataObject::GetAllFormats(wxDataFormat *formats,
 
 bool wxFileDataObject::GetDataHere(void *buf) const
 {
-    char* out = reinterpret_cast<char*>(buf);
+    char* out = static_cast<char*>(buf);
 
     for (size_t i = 0; i < m_filenames.GetCount(); i++)
     {
@@ -243,10 +243,11 @@ bool wxFileDataObject::GetDataHere(void *buf) const
         if (uri)
         {
             size_t const len = strlen(uri);
-            strcpy(out, uri);
+            memcpy(out, uri, len);
             out += len;
             *(out++) = '\r';
             *(out++) = '\n';
+            g_free(uri);
         }
     }
     *out = 0;