浏览代码

hwcontext_opencl: Only release command queue if it exists

If the frames context creation fails then the command queue reference
need not exist when uninit is called.
Mark Thompson 7 年之前
父节点
当前提交
b9aff7a53d
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      libavutil/hwcontext_opencl.c

+ 7 - 4
libavutil/hwcontext_opencl.c

@@ -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;
     }
 }