Patch Detail
Show a patch.
GET /api/1.1/patches/17204/?format=api
{ "id": 17204, "url": "https://patchwork.libcamera.org/api/1.1/patches/17204/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17204/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20220826113931.59323-2-tomi.valkeinen@ideasonboard.com>", "date": "2022-08-26T11:39:30", "name": "[libcamera-devel,1/2] libcamera: base: log: Fix use of freed name", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "38495186bc2f2b66e01c19e99a3c97ea55d5e840", "submitter": { "id": 109, "url": "https://patchwork.libcamera.org/api/1.1/people/109/?format=api", "name": "Tomi Valkeinen", "email": "tomi.valkeinen@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17204/mbox/", "series": [ { "id": 3437, "url": "https://patchwork.libcamera.org/api/1.1/series/3437/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3437", "date": "2022-08-26T11:39:29", "name": "LogCategory fixing", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3437/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17204/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17204/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 66678C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 26 Aug 2022 11:39:46 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4E47B61FBB;\n\tFri, 26 Aug 2022 13:39:45 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A74E61FBB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Aug 2022 13:39:43 +0200 (CEST)", "from deskari.lan (91-158-154-79.elisa-laajakaista.fi\n\t[91.158.154.79])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B70363F1;\n\tFri, 26 Aug 2022 13:39:42 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1661513985;\n\tbh=DQfpMcbNtUoBdFmgnTbLvJ38yNa23qiAAEaj7/AVmwo=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=HjJIP1nPhcDpA9tc09mKlgJLc33MRQ3hAaxl//4Mf/o+cbx/q4Gw9b4AUtMdpBXsH\n\tISOhkxxyMejlq7ee7xpSYs2boVuIxC6Dj2iI+IkWs7tB3/322GO+P++dAhOw/HMHJy\n\tN6a60LCJwkZlGxtr0EiM0LCw+gStvFo1EnmPmES4DSMwc8WJF1cgzWqG1Mec4vyOzE\n\tgRy/jFNh6rDDGZhsDWrFQghIA6R5eZvPdb7P4uHEJokmO97ct8Pdpgv02HKWocGwGk\n\tUEOv7efXIWt3IY8dE7vfCUipSPSgL29xTQQurP/xsGQ2otLN4rKR3Fqc08qCnmXgk1\n\tKuXuU2SVtNO/w==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1661513982;\n\tbh=DQfpMcbNtUoBdFmgnTbLvJ38yNa23qiAAEaj7/AVmwo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=hEQQoZj05JY1/Us71QKqwwGONBQNkVdZDt2XUbKk9GX9UIVrHCpbIKhwH2kc8I5Ua\n\tpwTmLYziouNfD/MaJFAKZdbPZ8jDZ6SDFEvwcC/LtYF7Bpd+qe9a8J0QH+ITaCe0mf\n\tNlntZPO7lRzFuZyEsIABMT6vWD3uN813KS9v1OcA=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"hEQQoZj0\"; dkim-atps=neutral", "To": "libcamera-devel <libcamera-devel@lists.libcamera.org>", "Date": "Fri, 26 Aug 2022 14:39:30 +0300", "Message-Id": "<20220826113931.59323-2-tomi.valkeinen@ideasonboard.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220826113931.59323-1-tomi.valkeinen@ideasonboard.com>", "References": "<20220826113931.59323-1-tomi.valkeinen@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 1/2] libcamera: base: log: Fix use of\n\tfreed name", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "From": "Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "LogCategory just stores the char * that was given to it in the\nconstructor, i.e. it refers to memory \"outside\" LogCategory. If the\nLogCategory is defined in a .so that is unloaded, then it leads to the\nLogCategory pointing to freed memory, causing a crash.\n\nFix this by taking a copy of the name by using a std::string instead of\njust storing the pointer.\n\nSigned-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n---\n include/libcamera/base/log.h | 4 ++--\n src/libcamera/base/log.cpp | 2 +-\n 2 files changed, 3 insertions(+), 3 deletions(-)", "diff": "diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h\nindex 3fc5ced3..8b462767 100644\n--- a/include/libcamera/base/log.h\n+++ b/include/libcamera/base/log.h\n@@ -31,14 +31,14 @@ class LogCategory\n public:\n \texplicit LogCategory(const char *name);\n \n-\tconst char *name() const { return name_; }\n+\tconst std::string &name() const { return name_; }\n \tLogSeverity severity() const { return severity_; }\n \tvoid setSeverity(LogSeverity severity);\n \n \tstatic const LogCategory &defaultCategory();\n \n private:\n-\tconst char *name_;\n+\tconst std::string name_;\n \tLogSeverity severity_;\n };\n \ndiff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\nindex 5c359a22..a4a5b452 100644\n--- a/src/libcamera/base/log.cpp\n+++ b/src/libcamera/base/log.cpp\n@@ -568,7 +568,7 @@ void Logger::logSetLevel(const char *category, const char *level)\n \t\treturn;\n \n \tfor (LogCategory *c : categories_) {\n-\t\tif (!strcmp(c->name(), category)) {\n+\t\tif (c->name() == category) {\n \t\t\tc->setSeverity(severity);\n \t\t\tbreak;\n \t\t}\n", "prefixes": [ "libcamera-devel", "1/2" ] }