libs: encoder: Add NULL pointer check for context when finalize.
authorHe Junyan <junyan.he@hotmail.com>
Sun, 22 Dec 2019 07:22:57 +0000 (15:22 +0800)
committerHe Junyan <junyan.he@hotmail.com>
Sun, 22 Dec 2019 07:22:57 +0000 (15:22 +0800)
Context may be NULL if pipeline fail in early stage, and the
ensure_context will not be called. Need to add a pointer protection
for it.

gst-libs/gst/vaapi/gstvaapiencoder.c

index 2d29d04..3f0e9a7 100644 (file)
@@ -1345,7 +1345,8 @@ gst_vaapi_encoder_finalize (GObject * object)
 {
   GstVaapiEncoder *encoder = GST_VAAPI_ENCODER (object);
 
-  gst_vaapi_context_unref (encoder->context);
+  if (encoder->context)
+    gst_vaapi_context_unref (encoder->context);
   encoder->context = NULL;
   gst_vaapi_display_replace (&encoder->display, NULL);
   encoder->va_display = NULL;