Skip to content
Browse files

Fix possible undefined behaviours in libmythprotoserver

The intermediary QByteBuffer returned by toLocal8Bit would have been destroyed at the end of the expression, making the pointer used invalid.

Wondering what kind of crash/instability this would have caused.
I went through the whole code, and only found those two.

Thanks to Malcolm Parsons (pepsiman) for reporting a similar issue in 9ea5252.
  • Loading branch information...
1 parent 87b3f9c commit 5aaca58157c6456b88e500ccacbde91e31dcb534 @jyavenard jyavenard committed Apr 18, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 mythtv/libs/libmythprotoserver/requesthandler/deletethread.cpp
View
6 mythtv/libs/libmythprotoserver/requesthandler/deletethread.cpp
@@ -105,7 +105,8 @@ void DeleteThread::ProcessNew(void)
// continue;
QString path = handler->m_path;
- const char *cpath = handler->m_path.toLocal8Bit().constData();
+ QByteArray cpath_ba = handler->m_path.toLocal8Bit();
+ const char *cpath = cpath_ba.constData();
QFileInfo finfo(handler->m_path);
if (finfo.isSymLink())
@@ -137,7 +138,8 @@ void DeleteThread::ProcessNew(void)
// an external directory with no link into mythtv
handler->DeleteSucceeded();
handler->m_path = tmppath;
- cpath = handler->m_path.toLocal8Bit().constData();
+ cpath_ba = handler->m_path.toLocal8Bit();
+ cpath = cpath_ba.constData();
}
else
{

0 comments on commit 5aaca58

Please sign in to comment.
Something went wrong with that request. Please try again.