{"id":1992,"url":"https://patchwork.libcamera.org/api/1.1/patches/1992/?format=json","web_url":"https://patchwork.libcamera.org/patch/1992/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190923132229.17027-1-kieran.bingham@ideasonboard.com>","date":"2019-09-23T13:22:29","name":"[libcamera-devel] qcam: Fix ViewFinder memory leak","commit_ref":"f0b2582c4961ce9e5b637a2a326aa59ebc905e52","pull_url":null,"state":"accepted","archived":false,"hash":"78b92aa3d002c2d3a8d7d43ea18c4824298ef510","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/1.1/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1992/mbox/","series":[{"id":504,"url":"https://patchwork.libcamera.org/api/1.1/series/504/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=504","date":"2019-09-23T13:22:29","name":"[libcamera-devel] qcam: Fix ViewFinder memory leak","version":1,"mbox":"https://patchwork.libcamera.org/series/504/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1992/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1992/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["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 4049660BB0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Sep 2019 15:22:37 +0200 (CEST)","from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B009653B;\n\tMon, 23 Sep 2019 15:22:36 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1569244956;\n\tbh=OR/ng4fajGUOo0ZnJnHVDtOC4055fCBL33kuXRuCqcE=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=MZCfKlTdFTSfif8+kuA0zww6PcoznqbTUW/bdv33HJyqs+509m6BTp7Nn88Lh04Je\n\trUvTEfusTLA8NNbz6tgxW0xH7JSiJNva9tREi7aDXmBsl9in9b6Q+5O0xqPs/WZiKk\n\tNA0iPlmofuZmikN6bs50DgQ/CS10SbO1FAoPyHas=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Date":"Mon, 23 Sep 2019 14:22:29 +0100","Message-Id":"<20190923132229.17027-1-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.20.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] qcam: Fix ViewFinder memory leak","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Mon, 23 Sep 2019 13:22:37 -0000"},"content":"When setting the format on the ViewFinder, a new image_ is allocated.\nAny change in format deletes the existing allocation, but it is not\ncleaned up on shutdown:\n\nDirect leak of 32 byte(s) in 1 object(s) allocated from:\n    #0 0x7f0bf8a7e17f in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10e17f)\n    #1 0x564c7205f7b0 in ViewFinder::setFormat(unsigned int, unsigned int, unsigned int) ../src/qcam/viewfinder.cpp:43\n    #2 0x564c71fec467 in MainWindow::startCapture() ../src/qcam/main_window.cpp:152\n    #3 0x564c71fe6c1a in MainWindow::MainWindow(libcamera::CameraManager*, OptionsParser::Options const&) ../src/qcam/main_window.cpp:40\n    #4 0x564c71fdf133 in main ../src/qcam/main.cpp:76\n    #5 0x7f0bf5944b6a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26b6a)\n\nProvide a ViewFinder destructor, and delete the allocation as\nappropriate.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/qcam/viewfinder.cpp | 5 +++++\n src/qcam/viewfinder.h   | 1 +\n 2 files changed, 6 insertions(+)","diff":"diff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp\nindex 224a227ddd5b..98a8ab68e5f6 100644\n--- a/src/qcam/viewfinder.cpp\n+++ b/src/qcam/viewfinder.cpp\n@@ -16,6 +16,11 @@ ViewFinder::ViewFinder(QWidget *parent)\n {\n }\n \n+ViewFinder::~ViewFinder()\n+{\n+\tdelete image_;\n+}\n+\n void ViewFinder::display(const unsigned char *raw, size_t size)\n {\n \tconverter_.convert(raw, size, image_);\ndiff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h\nindex c9ca98913e05..33bdb1460f84 100644\n--- a/src/qcam/viewfinder.h\n+++ b/src/qcam/viewfinder.h\n@@ -17,6 +17,7 @@ class ViewFinder : public QLabel\n {\n public:\n \tViewFinder(QWidget *parent);\n+\t~ViewFinder();\n \n \tint setFormat(unsigned int format, unsigned int width,\n \t\t      unsigned int height);\n","prefixes":["libcamera-devel"]}