[libcamera-devel] test: buffer_import: Initialize media_ and video_

Message ID 20190916201859.26553-1-jacopo@jmondi.org
State Accepted
Commit 0f2e8cac8dd43544adad50bf42b0fda496ddb055
Headers show
Series
  • [libcamera-devel] test: buffer_import: Initialize media_ and video_
Related show

Commit Message

Jacopo Mondi Sept. 16, 2019, 8:18 p.m. UTC
When the vivid module used to test buffer importing is not loaded, the
test correctly bails out, but during the clean up procedure tries to
access the video_ fields, which, if not correctly initialized to
nullptr, contains random values and accessing it cause a segfault.

Fix this by initializing video_ field to nullptr to make sure it is
properly handled in cleanup().

Fixes: e1a5873701a9 ("test: camera: Add buffer import and mapping test")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 test/camera/buffer_import.cpp | 5 +++++
 1 file changed, 5 insertions(+)

--
2.23.0

Comments

Jacopo Mondi Sept. 16, 2019, 8:25 p.m. UTC | #1
Pushed with an updated commit message too
"test: buffer_import: Initialize video_ to nullptr"

On Mon, Sep 16, 2019 at 10:18:59PM +0200, Jacopo Mondi wrote:
> When the vivid module used to test buffer importing is not loaded, the
> test correctly bails out, but during the clean up procedure tries to
> access the video_ fields, which, if not correctly initialized to
> nullptr, contains random values and accessing it cause a segfault.
>
> Fix this by initializing video_ field to nullptr to make sure it is
> properly handled in cleanup().
>
> Fixes: e1a5873701a9 ("test: camera: Add buffer import and mapping test")
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  test/camera/buffer_import.cpp | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp
> index 9364e3d1bc44..9cac19d8ce81 100644
> --- a/test/camera/buffer_import.cpp
> +++ b/test/camera/buffer_import.cpp
> @@ -28,6 +28,11 @@ static constexpr unsigned int CAMERA_BUFFER_COUNT = 4;
>  class FrameSink
>  {
>  public:
> +	FrameSink()
> +		: video_(nullptr)
> +	{
> +	}
> +
>  	int init()
>  	{
>  		int ret;
> --
> 2.23.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp
index 9364e3d1bc44..9cac19d8ce81 100644
--- a/test/camera/buffer_import.cpp
+++ b/test/camera/buffer_import.cpp
@@ -28,6 +28,11 @@  static constexpr unsigned int CAMERA_BUFFER_COUNT = 4;
 class FrameSink
 {
 public:
+	FrameSink()
+		: video_(nullptr)
+	{
+	}
+
 	int init()
 	{
 		int ret;