https://bugs.kde.org/show_bug.cgi?id=482137
--- Comment #9 from Marcel Hasler <mahas...@gmail.com> --- (In reply to Fabio from comment #7) > (In reply to Marcel Hasler from comment #6) > > This is a bug in RdpSession::start(). > > I confirm your patch fixes the issue. A small variant has been submitted > here: https://invent.kde.org/network/krdc/-/merge_requests/114 > > > 3. The pointer returned by m_preferences->shareMedia().toLocal8Bit().data() > > is no longer valid by the time it's passed to > > freerdp_client_add_device_channel, since it references a temporary object > > that no longer exists at this point > > FreeRDP internally calls _strdup on that parameter in > https://github.com/FreeRDP/FreeRDP/blob/stable-2.0/client/common/cmdline. > c#L185 , so it's safe to use I don't think this is really true. I actually wrote a small test out of curiosity and found that the data indeed remains accessible, even if the QByteArray has been destroyed at that point (I would have expected a segfault). Apparently Qt doesn't immediately free the memory when a QByteArray goes out of scope but keeps it around for reuse. But here's a simple example to show that you cannot rely on the data remaining valid: #include <QString> #include <iostream> auto main() -> int { char* data1 = nullptr; { QString test1 = "Test 1"; data1 = test1.toLocal8Bit().data(); } QString test2 = "Test 2"; char* data2 = test2.toLocal8Bit().data(); Q_UNUSED(data2); std::cout << data1 << std::endl; return 0; } -- You are receiving this mail because: You are watching all bug changes.