Patch Detail
Show a patch.
GET /api/patches/22314/?format=api
{ "id": 22314, "url": "https://patchwork.libcamera.org/api/patches/22314/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22314/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20241215181835.802589-2-pobrn@protonmail.com>", "date": "2024-12-15T18:18:44", "name": "[v1,2/2] gstreamer: allocator: gst_libcamera_allocator_new(): Fix memory leak", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "91e91a8774b6f565faabe4b1fefbcb0c9bdd4a88", "submitter": { "id": 133, "url": "https://patchwork.libcamera.org/api/people/133/?format=api", "name": "Pőcze Barnabás", "email": "pobrn@protonmail.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22314/mbox/", "series": [ { "id": 4883, "url": "https://patchwork.libcamera.org/api/series/4883/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4883", "date": "2024-12-15T18:18:38", "name": "[v1,1/2] gstreamer: allocator: Recognize FrameBufferAllocator errors", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4883/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22314/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22314/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 D61C4C32F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 15 Dec 2024 18:18:49 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 92F0D67F0B;\n\tSun, 15 Dec 2024 19:18:49 +0100 (CET)", "from mail-40133.protonmail.ch (mail-40133.protonmail.ch\n\t[185.70.40.133])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 226CC67EEE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 15 Dec 2024 19:18:47 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"wLGE5dBY\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1734286726; x=1734545926;\n\tbh=VaEtcHJmDLYbmV0UOK8kOblWps709eWmllhn1JaGG1E=;\n\th=Date:To:From:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=wLGE5dBY9kmDE5GdeU9HH1QnfHyUOdvmh6uJE5dr1AQ+qfcXIuG27jn76ZPQ8Nd7z\n\tYbWpNH1dyyMCunUVLlb/b401arNa147UPAjPljk1WpiZ0kxv6eVRPiMY0bD3z0oxlI\n\tSP2XeRCCokEO6HoeASjlMvYm7xiqQw9KTTLaaKTdXgmUyD7FX73vdOwZ45APbsK1+O\n\t/kr1JHjigMRNJU456HK0V6eyhtPGaKh1bKUsGl3iVzInnpyDdFF33drCn3rk22AQ2j\n\tCdhZkHcN8/N73QpLT3bgUaFOCiyOnGxH4uBpIU+i/WOlJhmgXONEujhU1cbWap43AD\n\t4fbOPR0wtbUrA==", "Date": "Sun, 15 Dec 2024 18:18:44 +0000", "To": "libcamera-devel@lists.libcamera.org", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>", "Subject": "[PATCH v1 2/2] gstreamer: allocator: gst_libcamera_allocator_new():\n\tFix memory leak", "Message-ID": "<20241215181835.802589-2-pobrn@protonmail.com>", "In-Reply-To": "<20241215181835.802589-1-pobrn@protonmail.com>", "References": "<20241215181835.802589-1-pobrn@protonmail.com>", "Feedback-ID": "20568564:user:proton", "X-Pm-Message-ID": "6b664643a81833612c4ac277b9d628614e80e1fd", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=utf-8", "Content-Transfer-Encoding": "quoted-printable", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "If `FrameBufferAllocator::allocate()` causes the construction to be\naborted, the allocated `GstLibcameraAllocator` will not be\ndeallocated properly. Use `g_autoptr()` to address this.\n\n`g_steal_pointer()` cannot be used because that evaluates to\nan expression of type `void *`, so one would need an extra static_cast.\nInstead, use `std::exchange()`.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n---\n src/gstreamer/gstlibcameraallocator.cpp | 10 ++++------\n 1 file changed, 4 insertions(+), 6 deletions(-)", "diff": "diff --git a/src/gstreamer/gstlibcameraallocator.cpp b/src/gstreamer/gstlibcameraallocator.cpp\nindex b0c84893a..341bd31b3 100644\n--- a/src/gstreamer/gstlibcameraallocator.cpp\n+++ b/src/gstreamer/gstlibcameraallocator.cpp\n@@ -199,15 +199,13 @@ GstLibcameraAllocator *\n gst_libcamera_allocator_new(std::shared_ptr<Camera> camera,\n \t\t\t CameraConfiguration *config_)\n {\n-\tauto *self = GST_LIBCAMERA_ALLOCATOR(g_object_new(GST_TYPE_LIBCAMERA_ALLOCATOR,\n-\t\t\t\t\t\t\t nullptr));\n+\tg_autoptr(GstLibcameraAllocator) self = GST_LIBCAMERA_ALLOCATOR(g_object_new(GST_TYPE_LIBCAMERA_ALLOCATOR,\n+\t\t\t\t\t\t\t\t\t\t nullptr));\n \tgint ret;\n \n \tself->cm_ptr = new std::shared_ptr<CameraManager>(gst_libcamera_get_camera_manager(ret));\n-\tif (ret) {\n-\t\tg_object_unref(self);\n+\tif (ret)\n \t\treturn nullptr;\n-\t}\n \n \tself->fb_allocator = new FrameBufferAllocator(camera);\n \tfor (StreamConfiguration &streamCfg : *config_) {\n@@ -228,7 +226,7 @@ gst_libcamera_allocator_new(std::shared_ptr<Camera> camera,\n \t\tg_hash_table_insert(self->pools, stream, pool);\n \t}\n \n-\treturn self;\n+\treturn std::exchange(self, nullptr);\n }\n \n bool\n", "prefixes": [ "v1", "2/2" ] }