From patchwork Thu Mar 7 15:43:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10843263 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 B9535139A for ; Thu, 7 Mar 2019 15:43:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A83EC2F440 for ; Thu, 7 Mar 2019 15:43:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C4B32F458; Thu, 7 Mar 2019 15:43:47 +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 521602F440 for ; Thu, 7 Mar 2019 15:43:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726352AbfCGPnr (ORCPT ); Thu, 7 Mar 2019 10:43:47 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55047 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726185AbfCGPnr (ORCPT ); Thu, 7 Mar 2019 10:43:47 -0500 Received: by mail-wm1-f67.google.com with SMTP id f3so9789031wmj.4 for ; Thu, 07 Mar 2019 07:43:45 -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=eMAX++wxUEb3/+S1k0GjhXMPAUaZXGR6sOY/EpkRX04=; b=EdQnTADByO41qYgOobNtLLS7HyOx/fApc8eKJ6HeVB9DfGLwzAF9VdY69B/wCtyWOq DKaR6xmwxkwO7CnUbs/r3NF5Vll25AaDCNcIjw0O+dMEbxVDmEu/JCgq4g4Ri3MliHVA AvWjhsi1sTVO9a8VKYz7IuiZZsr4KcbKIcoCuBk1I/ES8WB6c/LPYOIGWXCPtKE0M997 e0lk9jGQfEJcy89beaFaaycRY2q+CXE9sr5F4896hdnOlHuqLAW7CCm3d1yaEmteeI8h l1AKiEPIvmxMTKTyYEMEOV8PCz9nxH8WgYzrtw1PGyeqwHh09RGucKDRHx9v4B9mDFVX k5Rg== X-Gm-Message-State: APjAAAUXT0w4W2dPzUHDLIdhes3vXdmf7W+9SDX2dEu2paaCz4RVnYo6 0mhVc3ZMpYUOFAMAfNg7OvQ= X-Google-Smtp-Source: APXvYqxyl9fiML/SjsUPY2J01jQTpK1MI3H9zZuLgGfdAS1531h84ySzdlrnlUrm4tLCFsgNo4CGSg== X-Received: by 2002:a1c:dc0a:: with SMTP id t10mr6182738wmg.101.1551973425140; Thu, 07 Mar 2019 07:43:45 -0800 (PST) Received: from localhost.localdomain ([95.87.198.56]) by smtp.gmail.com with ESMTPSA id h9sm10081463wrv.11.2019.03.07.07.43.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 07:43:44 -0800 (PST) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, Yordan Karadzhov Subject: [PATCH v2 4/4] kernel-shark: Fix a bug in KsPluginManager Date: Thu, 7 Mar 2019 17:43:16 +0200 Message-Id: <20190307154316.19194-5-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190307154316.19194-1-ykaradzhov@vmware.com> References: <20190307154316.19194-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. 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); };