msdk: release resources if failing to create the buffer pool
authorHaihao Xiang <haihao.xiang@intel.com>
Wed, 9 Jan 2019 00:58:00 +0000 (08:58 +0800)
committerHaihao Xiang <haihao.xiang@intel.com>
Wed, 9 Jan 2019 01:42:56 +0000 (09:42 +0800)
Needn't check the pointers against NULL because the pointers are
non-NULL

sys/msdk/gstmsdkdec.c
sys/msdk/gstmsdkenc.c
sys/msdk/gstmsdkvpp.c

index 016122d..5d80ca4 100644 (file)
@@ -1112,11 +1112,14 @@ error_no_pool:
 error_no_allocator:
   {
     GST_INFO_OBJECT (thiz, "failed to create allocator");
+    gst_object_unref (pool);
     return NULL;
   }
 error_pool_config:
   {
     GST_INFO_OBJECT (thiz, "failed to set config");
+    gst_object_unref (pool);
+    gst_object_unref (allocator);
     return NULL;
   }
 }
index c3e16ce..6f90249 100644 (file)
@@ -952,11 +952,14 @@ error_no_pool:
 error_no_allocator:
   {
     GST_INFO_OBJECT (thiz, "failed to create allocator");
+    gst_object_unref (pool);
     return FALSE;
   }
 error_pool_config:
   {
     GST_INFO_OBJECT (thiz, "failed to set config");
+    gst_object_unref (pool);
+    gst_object_unref (allocator);
     return FALSE;
   }
 }
index d769d40..027037b 100644 (file)
@@ -304,22 +304,20 @@ error_no_pool:
 error_no_video_info:
   {
     GST_INFO_OBJECT (thiz, "Failed to get Video info from caps");
+    gst_object_unref (pool);
     return NULL;
   }
 error_no_allocator:
   {
     GST_INFO_OBJECT (thiz, "Failed to create allocator");
-    if (pool)
-      gst_object_unref (pool);
+    gst_object_unref (pool);
     return NULL;
   }
 error_pool_config:
   {
     GST_INFO_OBJECT (thiz, "Failed to set config");
-    if (pool)
-      gst_object_unref (pool);
-    if (allocator)
-      gst_object_unref (allocator);
+    gst_object_unref (pool);
+    gst_object_unref (allocator);
     return NULL;
   }
 }