mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 10:41:04 +00:00
plugins: avoid possible memory leaks
Get the pool config just before use it, to avoid a memory leak if the allocator cannot be instantiated. Similarly, return FALSE if the configuration cannot be set, avoid keep a not used allocator in the pool.
This commit is contained in:
parent
8d7a0ae16c
commit
4c99077af4
1 changed files with 6 additions and 4 deletions
|
@ -495,21 +495,23 @@ set_dmabuf_allocator (GstVaapiPluginBase * plugin, GstBufferPool * pool,
|
|||
GstStructure *config;
|
||||
GstAllocator *allocator;
|
||||
GstVideoInfo vi;
|
||||
gboolean ret;
|
||||
|
||||
if (!gst_video_info_from_caps (&vi, caps))
|
||||
return FALSE;
|
||||
config = gst_buffer_pool_get_config (pool);
|
||||
allocator = gst_vaapi_dmabuf_allocator_new (plugin->display, &vi,
|
||||
GST_VAAPI_SURFACE_ALLOC_FLAG_LINEAR_STORAGE);
|
||||
if (!allocator)
|
||||
return FALSE;
|
||||
|
||||
config = gst_buffer_pool_get_config (pool);
|
||||
gst_buffer_pool_config_set_allocator (config, allocator, NULL);
|
||||
ret = gst_buffer_pool_set_config (pool, config);
|
||||
if (!gst_buffer_pool_set_config (pool, config))
|
||||
return FALSE;
|
||||
|
||||
if (plugin->sinkpad_allocator)
|
||||
gst_object_unref (plugin->sinkpad_allocator);
|
||||
plugin->sinkpad_allocator = allocator;
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
Loading…
Reference in a new issue