mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
va: allocator: Fix possible memory leaks
At gst_va_dmabuf_allocator_setup_buffer_full, static code analysis tool does not know number of objects in descriptor is always larger than 0 if export_surface_to_dmabuf succeeds. Thus, the tool will assume buf is allocated with mem but not released when desc.num_objects equals to 0 and raise a mem leak issue. For gst_va_dambuf_memories_setup, we should also inform the tool that n_planes will be larger than 0 by checking the value at very beginning. Then, the defect similar to above will not be raised during static analysis. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1241>
This commit is contained in:
parent
8e3f8e6f7d
commit
164244a2eb
1 changed files with 7 additions and 1 deletions
|
@ -541,6 +541,11 @@ gst_va_dmabuf_allocator_setup_buffer_full (GstAllocator * allocator,
|
|||
goto failed;
|
||||
}
|
||||
|
||||
if (desc.num_objects == 0) {
|
||||
GST_ERROR ("Failed to export surface to dmabuf");
|
||||
goto failed;
|
||||
}
|
||||
|
||||
buf = gst_va_buffer_surface_new (surface, format, desc.width, desc.height);
|
||||
if (G_UNLIKELY (info)) {
|
||||
*info = self->info;
|
||||
|
@ -811,7 +816,8 @@ gst_va_dmabuf_memories_setup (GstVaDisplay * display, GstVideoInfo * info,
|
|||
gboolean ret;
|
||||
|
||||
g_return_val_if_fail (GST_IS_VA_DISPLAY (display), FALSE);
|
||||
g_return_val_if_fail (n_planes <= GST_VIDEO_MAX_PLANES, FALSE);
|
||||
g_return_val_if_fail (n_planes > 0
|
||||
&& n_planes <= GST_VIDEO_MAX_PLANES, FALSE);
|
||||
|
||||
format = GST_VIDEO_INFO_FORMAT (info);
|
||||
if (format == GST_VIDEO_FORMAT_UNKNOWN)
|
||||
|
|
Loading…
Reference in a new issue