From patchwork Tue Mar 26 13:39:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10871211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE6F2922 for ; Tue, 26 Mar 2019 13:39:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB062262FF for ; Tue, 26 Mar 2019 13:39:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEEE12864B; Tue, 26 Mar 2019 13:39:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 715FD262FF for ; Tue, 26 Mar 2019 13:39:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726266AbfCZNj3 (ORCPT ); Tue, 26 Mar 2019 09:39:29 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:32910 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726175AbfCZNj3 (ORCPT ); Tue, 26 Mar 2019 09:39:29 -0400 Received: by mail-wr1-f65.google.com with SMTP id q1so14421066wrp.0 for ; Tue, 26 Mar 2019 06:39:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rcXwAu319jdI0gNay8qXKcIDNBI8LPnJYobHrCTv3Xc=; b=mTGgKoyw8WRhcaIVmWfYTERjK+gdaLIjzHnKzKjAE09wLWgL2lZa9mGQ1noChZ8HCd mFoVmKq4UP6odOfm3lUNsy3c1JQAavgCzg3lWQBUP9RpN9Dw3MIi0vxCwJ/r2SxbC0E6 Luf+KGoN7bmDVANQ0s0VnqY5kSTonjgD0EeNQMmXWb4y0kiAf13pfExjnvULoQkKS0Uc E2E9YNtadF53fbg8pB5+o7z0IAlUh843Xc1ZEFIX47f7OzajEgtiUd1RL5hb95qJTAsl XcY4aaluXhov1Flv6QZb5rreEuvLcsTxgWR+OB2r5cotyeQQTpiQVJsEjUyaQJjtAVSo Z23g== X-Gm-Message-State: APjAAAU329SnWKUGSjlC2zWevf6VdhVp0Tdm/2ZplNipih+5M7XJSWrm 8qtKmfIImXMQZH6+YTKoMZg= X-Google-Smtp-Source: APXvYqx52/ZsDDu3kD5kN9aK9HfMYpWsEpYPQzcyaUPxG/KYtu8oDpKPYmXltaxum/6IYeFK0vuT6w== X-Received: by 2002:a5d:4c88:: with SMTP id z8mr12247077wrs.291.1553607567366; Tue, 26 Mar 2019 06:39:27 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id r16sm8485718wrx.37.2019.03.26.06.39.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 06:39:27 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v3] kernel-shark: Fix a bug in KsPluginManager Date: Tue, 26 Mar 2019 15:39:14 +0200 Message-Id: <20190326133914.18884-1-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Yordan Karadzhov --- 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,