From 3423e6533b571566227d1363efc0bb2bc877a41c Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Fri, 2 Oct 2015 09:12:17 -0700 Subject: [PATCH] Fix memory leak introduced in 3b047b58 Also, use memcpy() instead of strcpy() since we already have the length, and use static_cast instead of reinterpret_cast. --- src/gtk/dataobj.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gtk/dataobj.cpp b/src/gtk/dataobj.cpp index 1754d6cda9..afdea3f3ee 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(buf); + char* out = static_cast(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;