mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-12 23:09:45 +03:00
gstreamer: Fix leak of GstQuery and GstBufferPool in error path
The gst_libcamera_create_video_pool() function leaks a GstQuery instance and a GstBufferPool instance in an error path. Fix the leaks with g_autoptr(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
This commit is contained in:
parent
f7c4fcd301
commit
772b06bd8c
1 changed files with 4 additions and 4 deletions
|
@ -30,6 +30,7 @@
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <libcamera/camera.h>
|
#include <libcamera/camera.h>
|
||||||
|
@ -540,9 +541,9 @@ static std::tuple<GstBufferPool *, int>
|
||||||
gst_libcamera_create_video_pool(GstLibcameraSrc *self, GstPad *srcpad,
|
gst_libcamera_create_video_pool(GstLibcameraSrc *self, GstPad *srcpad,
|
||||||
GstCaps *caps, const GstVideoInfo *info)
|
GstCaps *caps, const GstVideoInfo *info)
|
||||||
{
|
{
|
||||||
GstQuery *query = NULL;
|
g_autoptr(GstQuery) query = NULL;
|
||||||
|
g_autoptr(GstBufferPool) pool = NULL;
|
||||||
const gboolean need_pool = true;
|
const gboolean need_pool = true;
|
||||||
GstBufferPool *pool = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the peer allocation hints to check if it supports the meta API.
|
* Get the peer allocation hints to check if it supports the meta API.
|
||||||
|
@ -586,8 +587,7 @@ gst_libcamera_create_video_pool(GstLibcameraSrc *self, GstPad *srcpad,
|
||||||
return { NULL, -EINVAL };
|
return { NULL, -EINVAL };
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_query_unref(query);
|
return { std::exchange(pool, nullptr), 0 };
|
||||||
return { pool, 0 };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Must be called with stream_lock held. */
|
/* Must be called with stream_lock held. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue