From 2e0a51264f2d8dfdb2ffe016742f6dd52b0f15e2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 7 May 2014 21:57:08 -0700 Subject: Fix another dangling pointer Same problem as the previous commit: toStdString() returns a temporary, and c_str() will return a pointer to internal data, freed at the end of the statement. So get the pointer to be strcpy'ed in the same statement. Changed to toUtf8() to be more explicit about the encoding and to avoid std::string Signed-off-by: Thiago Macieira Signed-off-by: Dirk Hohndel --- qt-ui/profile/profilewidget2.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index f2fddb5e4..17eb2a3c4 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -841,10 +841,8 @@ void ProfileWidget2::editName() lengthWarning.exec(); return; } - const char *temp; - temp = newName.toStdString().c_str(); - strcpy(event->name, temp); - remember_event(temp); + strcpy(event->name, newName.toUtf8()); + remember_event(event->name); } replot(); } -- cgit v1.2.3-70-g09d2