linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] kernel-shark: Fix a bug in KsPluginManager
@ 2019-03-26 13:39 Yordan Karadzhov
  0 siblings, 0 replies; only message in thread
From: Yordan Karadzhov @ 2019-03-26 13:39 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

const char *lib = plugin.toStdString().c_str();

This line is a bad idea because the returned array may (will) be
invalidated when the destructor of std::string is called.

Fixes: 18cf94f48 ("kernel-shark-qt: Add KernalShark Utils")
Suggested-by: Slavomir Kaslev <kaslevs@vmware.com>
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/src/KsUtils.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp
index 34b2e2d..3585cca 100644
--- a/kernel-shark/src/KsUtils.cpp
+++ b/kernel-shark/src/KsUtils.cpp
@@ -439,8 +439,8 @@ void KsPluginManager::registerFromList(kshark_context *kshark_ctx)
 
 	auto lamRegUser = [&kshark_ctx](const QString &plugin)
 	{
-		const char *lib = plugin.toStdString().c_str();
-		kshark_register_plugin(kshark_ctx, lib);
+		std::string lib = plugin.toStdString();
+		kshark_register_plugin(kshark_ctx, lib.c_str());
 	};
 
 	_forEachInList(_ksPluginList,
@@ -474,8 +474,8 @@ void KsPluginManager::unregisterFromList(kshark_context *kshark_ctx)
 
 	auto lamUregUser = [&kshark_ctx](const QString &plugin)
 	{
-		const char *lib = plugin.toStdString().c_str();
-		kshark_unregister_plugin(kshark_ctx, lib);
+		std::string lib = plugin.toStdString();
+		kshark_unregister_plugin(kshark_ctx, lib.c_str());
 	};
 
 	_forEachInList(_ksPluginList,
-- 
2.19.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-03-26 13:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-26 13:39 [PATCH v3] kernel-shark: Fix a bug in KsPluginManager Yordan Karadzhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).