diff mbox

[FFmpeg-devel,2/4] hwcontext_opencl: Don't try to free an invalid queue in frames_uninit

Message ID 20180521223511.20395-2-sw@jkqxz.net
State New
Headers show

Commit Message

Mark Thompson May 21, 2018, 10:35 p.m. UTC
This can happen if frames_init fails.
---
 libavutil/hwcontext_opencl.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index c29a521f07..0d255e54e7 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -1739,10 +1739,12 @@  static void opencl_frames_uninit(AVHWFramesContext *hwfc)
     av_freep(&priv->mapped_frames);
 #endif
 
-    cle = clReleaseCommandQueue(priv->command_queue);
-    if (cle != CL_SUCCESS) {
-        av_log(hwfc, AV_LOG_ERROR, "Failed to release frame "
-               "command queue: %d.\n", cle);
+    if (priv->command_queue) {
+        cle = clReleaseCommandQueue(priv->command_queue);
+        if (cle != CL_SUCCESS) {
+            av_log(hwfc, AV_LOG_ERROR, "Failed to release frame "
+                   "command queue: %d.\n", cle);
+        }
     }
 }