diff options
author | He Junyan <junyan.he@hotmail.com> | 2020-02-07 23:56:13 +0800 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2020-03-06 12:40:48 +0000 |
commit | 5e612aeb849b678b046e8249657f2fb70b055572 (patch) | |
tree | 8d71f71fb1049a00753d4266bcd2ce0c8ed32f8d /gst-libs/gst | |
parent | da008baac29c3319cc13c0c3b20ce3669820458d (diff) |
libs: videopool: fix a condition race for pool allocate.
Diffstat (limited to 'gst-libs/gst')
-rw-r--r-- | gst-libs/gst/vaapi/gstvaapivideopool.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapivideopool.c b/gst-libs/gst/vaapi/gstvaapivideopool.c index faba3677..cb3ef3a6 100644 --- a/gst-libs/gst/vaapi/gstvaapivideopool.c +++ b/gst-libs/gst/vaapi/gstvaapivideopool.c @@ -179,6 +179,13 @@ gst_vaapi_video_pool_get_object_unlocked (GstVaapiVideoPool * pool) g_mutex_lock (&pool->mutex); if (!object) return NULL; + + /* Others already allocated a new one before us during we + release the mutex */ + if (pool->capacity && pool->used_count >= pool->capacity) { + gst_mini_object_unref (object); + return NULL; + } } ++pool->used_count; |