From ed26846a5439e9288965e48e22f0417b97042ef4 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Wed, 23 Jan 2013 17:30:44 +0200 Subject: [PATCH] Null terminate the wide string in torrent creator. --- src/torrentcreator/torrentcreatorthread.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/torrentcreator/torrentcreatorthread.cpp b/src/torrentcreator/torrentcreatorthread.cpp index 68803d97d..e8e91c03c 100644 --- a/src/torrentcreator/torrentcreatorthread.cpp +++ b/src/torrentcreator/torrentcreatorthread.cpp @@ -130,8 +130,9 @@ void TorrentCreatorThread::run() { // create the torrent and print it to out qDebug("Saving to %s", qPrintable(save_path)); #ifdef _MSC_VER - wchar_t *wsave_path = new wchar_t[save_path.length()]; - save_path.toWCharArray(wsave_path); + wchar_t *wsave_path = new wchar_t[save_path.length()+1]; + int len = save_path.toWCharArray(wsave_path); + wsave_path[len+1] = '\0'; std::ofstream outfile(wsave_path, std::ios_base::out|std::ios_base::binary); delete[] wsave_path; #else