hwcontext_opencl: Only release command queue if it exists
authorMark Thompson <sw@jkqxz.net>
Sun, 25 Nov 2018 19:14:27 +0000 (19:14 +0000)
committerMark Thompson <sw@jkqxz.net>
Wed, 28 Nov 2018 00:05:09 +0000 (00:05 +0000)
If the frames context creation fails then the command queue reference
need not exist when uninit is called.

libavutil/hwcontext_opencl.c

index 7288775..be71c83 100644 (file)
@@ -1726,10 +1726,13 @@ 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);
+        }
+        priv->command_queue = NULL;
     }
 }