From patchwork Thu Mar 7 15:05:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10843069 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 08DAB1575 for ; Thu, 7 Mar 2019 15:05:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB58D2F337 for ; Thu, 7 Mar 2019 15:05:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFB1E2F343; Thu, 7 Mar 2019 15:05:44 +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 86E0D2F337 for ; Thu, 7 Mar 2019 15:05:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726127AbfCGPFo (ORCPT ); Thu, 7 Mar 2019 10:05:44 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46124 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726242AbfCGPFo (ORCPT ); Thu, 7 Mar 2019 10:05:44 -0500 Received: by mail-wr1-f66.google.com with SMTP id i16so17798894wrs.13 for ; Thu, 07 Mar 2019 07:05:43 -0800 (PST) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=NdMzN8MIJtdVLbpS/kta7Rs50VSBU0N/4h520Ka2nEs=; b=dFoeTI6jRpQuv6R8xPl/rvsV1ZdGo+FY2/s3xusAyyEQUE3MRnGtnVEAqpzz6jrHw4 gL9VwKCnfTkfhvMfwpUMD10iSt3aXP+clEnp7dfRZ1Bx7vnfAFOx8qubW3468l2yzQIM mUazyTu6llf6HwqnS2P+MmxAYaJFafL+Gq7Lr8yY/t0iLu2oe1xxdHztMkbTfqB4x+Yu s8HIpMcm8mtG91wqCzi5rQTru8Ib3kmu/qULO7I7IyN3emhcyG6G21MA2tZLwQ6q6t6N aTaTeR6r6FIPH0/DFg0X0ULvwwpcR1CX+NzSQHvWvi/8Me1btcTv9Ap0S6NFiZH2Enmz lhTA== X-Gm-Message-State: APjAAAUkuADuKc+WCP/yWbo4WHDeUfui7XzfXW3yebxJ2mXkUmhnt7wx LBx97K2qlrAF4ipQ+ckpXkEF4cB0dYA= X-Google-Smtp-Source: APXvYqw7w74Q2E0RB8xz8SJ+/qy6tLtB7NiGArjPocqfXyM68cetHXdskwM22gxx2EWNyAMOu+DUzQ== X-Received: by 2002:adf:cd0b:: with SMTP id w11mr2340615wrm.95.1551971142436; Thu, 07 Mar 2019 07:05:42 -0800 (PST) Received: from localhost.localdomain ([95.87.198.56]) by smtp.gmail.com with ESMTPSA id d15sm10281274wrw.36.2019.03.07.07.05.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 07:05:42 -0800 (PST) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, Yordan Karadzhov Subject: [PATCH 4/4] kernel-shark: Fix a bug in KsPluginManager Date: Thu, 7 Mar 2019 17:05:11 +0200 Message-Id: <20190307150511.17246-5-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190307150511.17246-1-ykaradzhov@vmware.com> References: <20190307150511.17246-1-ykaradzhov@vmware.com> 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: 18cf94f485("kernel-shark-qt: Add KernalShark Utils") Signed-off-by: Yordan Karadzhov --- kernel-shark/src/KsUtils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel-shark/src/KsUtils.cpp b/kernel-shark/src/KsUtils.cpp index 34b2e2d..d7b1753 100644 --- a/kernel-shark/src/KsUtils.cpp +++ b/kernel-shark/src/KsUtils.cpp @@ -439,7 +439,7 @@ void KsPluginManager::registerFromList(kshark_context *kshark_ctx) auto lamRegUser = [&kshark_ctx](const QString &plugin) { - const char *lib = plugin.toStdString().c_str(); + const char *lib = plugin.toLocal8Bit().data(); kshark_register_plugin(kshark_ctx, lib); }; @@ -474,7 +474,7 @@ void KsPluginManager::unregisterFromList(kshark_context *kshark_ctx) auto lamUregUser = [&kshark_ctx](const QString &plugin) { - const char *lib = plugin.toStdString().c_str(); + const char *lib = plugin.toLocal8Bit().data(); kshark_unregister_plugin(kshark_ctx, lib); };