[Libva] [libva-intel-driver PATCH] Check pointer against NULL first before dereferencing it

Xiang, Haihao haihao.xiang at intel.com
Sun Sep 6 18:29:38 PDT 2015


Signed-off-by: Xiang, Haihao <haihao.xiang at intel.com>
---
 src/i965_drv_video.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 76fbbbd..f536dcc 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -6354,20 +6354,20 @@ i965_Terminate(VADriverContextP ctx)
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     int i;
 
-    if (i965->wrapper_pdrvctx) {
-       VADriverContextP pdrvctx;
-       pdrvctx = i965->wrapper_pdrvctx;
-       if (pdrvctx->handle) {
-           pdrvctx->vtable->vaTerminate(pdrvctx);
-           dlclose(pdrvctx->handle);
-           pdrvctx->handle = NULL;
-       }
-       free(pdrvctx->vtable);
-       free(pdrvctx);
-       i965->wrapper_pdrvctx = NULL;
-    }
-
     if (i965) {
+        if (i965->wrapper_pdrvctx) {
+            VADriverContextP pdrvctx;
+            pdrvctx = i965->wrapper_pdrvctx;
+            if (pdrvctx->handle) {
+                pdrvctx->vtable->vaTerminate(pdrvctx);
+                dlclose(pdrvctx->handle);
+                pdrvctx->handle = NULL;
+            }
+            free(pdrvctx->vtable);
+            free(pdrvctx);
+            i965->wrapper_pdrvctx = NULL;
+        }
+
         for (i = ARRAY_ELEMS(i965_sub_ops); i > 0; i--)
             if (i965_sub_ops[i - 1].display_type == 0 ||
                 i965_sub_ops[i - 1].display_type == (ctx->display_type & VA_DISPLAY_MAJOR_MASK)) {
-- 
1.9.1



More information about the Libva mailing list